BSON encoding/decoding performance improvements

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Python Drivers
    • 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: