BSON performance regression in Python 3.12

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Won't Do
    • Priority: Major - P3
    • 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

      There seems to be a BSON performance regression in Python 3.12. Discovered because PYTHON-5203 just upgraded our perf benchmarks from Python 3.10 to 3.13 and multiple BSON benchmarks dropped by 40%:
      https://spruce.mongodb.com/task/mongo_python_driver_perf_tests_perf_8.0_standalone_e6e8650cc95314e742a30244b5db0239f5259f68_25_03_13_19_08_41/trend-charts?execution=0&sortBy=STATUS&sortDir=ASC

      I can reproduce a regression in Python 3.12 and Python3.13 locally as well. Here's 3.10:

      platform darwin -- Python 3.10.11, pytest-8.3.5, pluggy-1.5.0 -- /Users/shane/work/pycharm/pymongo-py310/bin/python
      ...
      test/performance/perf_test.py::TestFlatEncoding::runTest Completed TestFlatEncoding 660.347 MB/s, MEDIAN=0.009s, total time=0.100s, iterations=10
      

      3.11:

      platform darwin -- Python 3.11.4, pytest-8.3.4, pluggy-1.5.0 -- /Users/shane/work/pycharm/pymongo-py311/bin/python
      ...
      test/performance/perf_test.py::TestFlatEncoding::runTest Completed TestFlatEncoding 657.964 MB/s, MEDIAN=0.009s, total time=0.101s, iterations=10
      

      3.12:

      platform darwin -- Python 3.12.4, pytest-8.3.3, pluggy-1.5.0 -- /Users/shane/work/pycharm/pymongo-py312/bin/python
      ...
      test/performance/perf_test.py::TestFlatEncoding::runTest Completed TestFlatEncoding 489.287 MB/s, MEDIAN=0.012s, total time=0.110s, iterations=8
      

      3.13:

      platform darwin -- Python 3.13.0, pytest-8.3.4, pluggy-1.5.0 -- /Users/shane/work/pycharm/pymongo-3.13/bin/python
      ...
      test/performance/perf_test.py::TestFlatEncoding::runTest Completed TestFlatEncoding 516.190 MB/s, MEDIAN=0.012s, total time=0.106s, iterations=8
      

            Assignee:
            Noah Stapp
            Reporter:
            Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: