[SERVER-55043] canonicalizeBSONType() should be implemented as a lookup table Created: 08/Mar/21 Updated: 29/Oct/23 Resolved: 14/Jan/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code, Performance |
| Affects Version/s: | None |
| Fix Version/s: | 5.3.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Mathias Stearn | Assignee: | Jordi Olivares Provencio |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | neweng, newgrad | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Backwards Compatibility: | Fully Compatible |
| Sprint: | Execution Team 2021-03-22, Execution Team 2022-01-10, Execution Team 2022-01-24 |
| Participants: |
| Description |
|
I noticed it was showing up as hot in some profiles. Making it a lookup table makes it basically disappear. I'm attaching a patch for how I did it. It may make sense to move the table construction out of line (I don't know if we are ever getting any benefit from calling this on a known-constant value), but the lookup should probably stay inline since it is just 2-3 instructions (possibly compute the address of the table using rip-relative addressing, sign extend the type, do the lookup). Canonicalizing 2 types (as is usually done) takes only 5 instructions because the actual table address only needs to be computed once. |
| Comments |
| Comment by Githook User [ 14/Jan/22 ] |
|
Author: {'name': 'Jordi Olivares Provencio', 'email': 'jordi.olivares-provencio@mongodb.com', 'username': 'jordiolivares'}Message: |
| Comment by Mathias Stearn [ 09/Mar/21 ] |
|
I replaced the patch with a cleaner one. It does all indexing with uint8_t so it generates equally good code without needing to work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99470 |