[SERVER-82832] Stop creating and destroying unnecessary vectors in checkAndAssertTypes Created: 06/Nov/23 Updated: 23/Nov/23 Resolved: 23/Nov/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.3.0-rc0 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Vishnu Kaushik | Assignee: | Vishnu Kaushik |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||
| Issue Links: |
|
||||
| Backwards Compatibility: | Fully Compatible | ||||
| Sprint: | Repl 2023-11-13, Repl 2023-11-27 | ||||
| Participants: | |||||
| Description |
|
The IDL parser generator produces code of the form var.checkAndAssertTypes("Context", {BSONType1, BSONType2, ...}) , i.e. it produces code where a BSONType[] is passed to checkAndAssertTypes(). However, since this function expects a vector, the BSONType[] is repeatedly converted to a vector and then destroyed right after the function call. Instead we can pass in pointers and make this a lot quicker to avoid many allocations and frees. In the attached screenshots, the functions highlighted in purple represent amount of time spent doing this. The more elaborate screenshot is from a debug build, and there we see that the construction & destruction of vectors take about 40% of parse time. In the opt=on build, the construction & destruction take 20% of the total time |
| Comments |
| Comment by Githook User [ 22/Nov/23 ] |
|
Author: {'name': 'kauboy26', 'email': 'vishnu.kaushik@mongodb.com', 'username': 'kauboy26'}Message: |