[SERVER-8663] Slow performance on duplicate key exception Created: 22/Feb/13 Updated: 14/May/15 Resolved: 14/May/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Performance |
| Affects Version/s: | 2.2.2 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Antoine Girbal | Assignee: | Mathias Stearn |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Participants: |
| Description |
|
While doing testing with C++ driver, I noticed that when all I tried with the very simple loop in js, and gives even worse result: var start = new Date(); Collection is empty: 2nd run without dropping: this is reproducible always.. |
| Comments |
| Comment by Mathias Stearn [ 22/Feb/13 ] |
|
antoine, That case only comes up in the rare case that we can't do two-phase indexing. In the normal case we never need to roll-back the insert since it hasn't occured yet (we check if the insert will work before doing it). My profiling suggests that all of the overhead is due to exception-unwind overhead. Most C++ compliers use "zero-cost" exceptions which makes it free to enter try-block and move all of the work of figuring out how to handle the exception into the throw case. This extra work is why the dup-key case is slower than then clean insert case. We may be able to optimize some of this away, but I don't know if it is worth it as I'm able to do ~20k dup-key inserts per second on my machine. Anything even approaching that number is likely to be a serious bug in user code anyway. |
| Comment by Antoine Girbal [ 22/Feb/13 ] |
|
I've tried to profile with gprof but mongod keeps hanging after a few Looking at our code a bit, I see on dup key we do this: // normal case – we can roll back Is it expected to be slower, since we actually insert then remove the |
| Comment by Antoine Girbal [ 22/Feb/13 ] |
|
Reproduced with 2.0 and 2.2. straight inserts (no preexisting): inserts all dups: upserts: |