[SERVER-76788] Elide useless constructor calls for trivially-constructible Decorations Created: 03/May/23 Updated: 22/Jan/24 Resolved: 06/Jun/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.1.0-rc0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Andy Schwerin | Assignee: | Billy Donahue |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | perf-servicearch | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||
| Assigned Teams: |
Service Arch
|
||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||
| Backport Requested: |
v7.0
|
||||||||||||||||||||||||
| Sprint: | Service Arch 2023-05-15, Service Arch 2023-05-29, Service Arch 2023-06-12 | ||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Description |
|
Decoration construction, especially for OperationContext takes a significant amount of time, as there is a very high number of decorations on that type. The cost comes from virtual function dispatch to invoke the constructors. Many of the decorations are trivially constructible and so don't really need any action taken at construction. The task of this ticket is to figure out how to avoid invoking constructor functions that don't need to do any work in order to speed up the construction and destruction of Decorable objects. Presumably this would be similar to If we cannot do this, we should instead investigate combining related decorations into structures to reduce the number of constructor/destructor actions. |
| Comments |
| Comment by Ger Hartnett [ 11/Sep/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
kyle.suarez@mongodb.com said:
david.daly@mongodb.com agreed. Kyle did you mean backporting this to 7.0? If so, do we need a BACKPORT ticket? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by David Daly [ 06/Jun/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Kyle Suarez [ 31/May/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
billy.donahue@mongodb.com / blake.oler@mongodb.com, is there more work to be done on this ticket or should it be closed out? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 19/May/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Billy Donahue [ 18/May/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
initial commit left out the copyable decoration containers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Billy Donahue [ 18/May/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
decorations_all.txt They are:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Billy Donahue [ 17/May/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm kind of skeptical of my own results because this should only affect trivially constructible decorations, and I don't see that many std::trivially_constructible decorations on OperationContext the only per-command decorable. Doing a little survey now to see just how many decorations this affected and didn't affect. Here are all the decorations on OperationContext, from an instrumented mongod that prints a log line in declareDecoration.
The ONLY trivial decorations are the 6 out of 55 (11%) that are bool. This needs more investigation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 17/May/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Billy Donahue [ 16/May/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Billy Donahue [ 12/May/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
irina.yatsenko@mongodb.com interesting signal boost for this ticket, thanks! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Irina Yatsenko (Inactive) [ 11/May/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Constructing class Snapshot : public Decorable<Snapshot> is responsible for some (1-2%) of the regression in https://jira.mongodb.org/browse/PERF-3818 (updateMany with no filter on a collection with 50K docs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andy Schwerin [ 03/May/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
We should also microbenchmark the construction of OperationContext and Client as decorated inside mongod in particular. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Billy Donahue [ 03/May/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|