[SERVER-78081] Optimize memory footprint of optional fields in query_stats::KeyGenerators Created: 14/Jun/23 Updated: 29/Oct/23 Resolved: 18/Jul/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: | Charlie Swanson | Assignee: | William Qian |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Query Optimization
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Sprint: | QO 2023-06-26, QO 2023-07-10, QO 2023-07-24 | ||||||||
| Participants: | |||||||||
| Linked BF Score: | 164 | ||||||||
| Description |
|
I was reading over this page after I was surprised by the size of some of these objects: https://www.boost.org/doc/libs/1_59_0/libs/optional/doc/html/boost_optional/tutorial/performance_considerations.html
It is probably worth doing some of that bool _has_allow_partial_results pattern rather than all the boost::optionals we have here: https://github.com/mongodb/mongo/blob/cf00278a5230148eaf71c04df84f6c6de77decee/src/mongo/db/query/query_stats_find_key_generator.h#L91 |
| Comments |
| Comment by Githook User [ 13/Jul/23 ] |
|
Author: {'name': 'William Qian', 'email': 'william.qian@mongodb.com', 'username': 'wqian94'}Message: |
| Comment by Githook User [ 12/Jul/23 ] |
|
Author: {'name': 'liubov.molchanova', 'email': 'liubov.molchanova@mongodb.com', 'username': 'liubov-molchanova'}Message: Revert " This reverts commit 41a8b3b19f57681424bbdbe98afdb307e1d58e46. |
| Comment by Githook User [ 11/Jul/23 ] |
|
Author: {'name': 'William Qian', 'email': 'william.qian@mongodb.com', 'username': 'wqian94'}Message: |
| Comment by William Qian [ 21/Jun/23 ] |
|
We could also consider using bit fields. Something like BSONObj _readConcern; struct { should do the trick. `hasfield` is 1B, so this should be `sizeof (BSONObj) + 16` bytes. (`_allowPartialResults`, `_noCursorTimeout`, and `hasField` all have alignments and sizes of 1.) |