BSON encoding/decoding performance improvements

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Python Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Investigations into PYTHON-5211 have identified at least four optimizations to improve BSON encoding/decoding performance:

      1. Skip _type_marker lookup for common built-in types.
      2. Use PyDict_New() instead of PyObject_CallObject() where possible.
      3. Use PyDict_SetItem() instead of PyObject_SetItem() where possible.
      4. Use PyObject_Vectorcall() and its ilk instead of PyObject_CallFunctionObjArgs() and similar functions.

      These four together improve performance by up to ~25% on our encoding and decoding BSON benchmarks consistently across Python versions.

            Assignee:
            Noah Stapp
            Reporter:
            Noah Stapp
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: