Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-55043

canonicalizeBSONType() should be implemented as a lookup table

    • Fully Compatible
    • Execution Team 2021-03-22, Execution Team 2022-01-10, Execution Team 2022-01-24

      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.

            jordi.olivares-provencio@mongodb.com Jordi Olivares Provencio
            mathias@mongodb.com Mathias Stearn
            0 Vote for this issue
            6 Start watching this issue