Improve bson handling of datetime

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: BSON, Performance
    • 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

      Context

      While working on PYTHON-5965, I found a performance win that affects the existing
      bson. I measured about a 15% improvement on a spawn perf host on the standard bson tests. I measured a 52% encode and 19% decode performance increase for datetime objects using the  Howard Hinnant algorithm, which is MIT licensed.

      Definition of done

      • Replace the time64 library's loop-based calendar math with Hinnant's O(1) algorithm: cbson_timegm64 (encode) iterates year-by-year from 1970 (~8000 iterations for year 9999), and cbson_gmtime64_r (decode) loops per-year.
      • Swap millis_from_datetime/datetime_from_millis over to days_from_civil/civil_from_days and drop the time64 sources.
      • Remove bson/time64.c|time64.h|time64_config.h|time64_limits.h
      • Verify no regression in round trip values

      Pitfalls

      We need to verify calendar-math correctness across year 1..9999 and negative/epoch boundaries.
      Compare the new implementation against the known-good reference across many inputs, AND verify data survives a full encode → decode loop.
      Also verify that test_bson_corpus.py passes.

            Assignee:
            Unassigned
            Reporter:
            Steve Silvester
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: