Optimize multi-field updates on wide documents: avoid repeated linear child lookups in UpdateObjectNode

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Product Performance
    • ALL
    • Hide

      step1: 

      {{./bin/ycsb.sh load mongodb -s -P workloads/workloada \
      -p mongodb.url='mongodb://<user>:<pass>@host1:port1,host2:port2,host3:port3/admin' \
      -p table=test -threads 100 -p recordcount=100000 -p fieldcount=5000}}

      step2:

       

      {{./bin/ycsb.sh run mongodb -s -P workloads/workloada \
      -p mongodb.url='mongodb://<user>:<pass>@host1:port1,host2:port2,host3:port3/admin?authSource=admin&replicaSet=rs0' \
      -p table=test -threads 100 -p recordcount=100000 \
      -p readproportion=0 -p updateproportion=1 -p insertproportion=0 \
      -p operationcount=50000 -p fieldcount=500 -p writeallfields=true}}

      Show
      step1:  {{./bin/ycsb.sh load mongodb -s -P workloads/workloada \ -p mongodb.url='mongodb://<user>:<pass>@host1:port1,host2:port2,host3:port3/admin' \ -p table=test -threads 100 -p recordcount=100000 -p fieldcount=5000}} step2:   {{./bin/ycsb.sh run mongodb -s -P workloads/workloada \ -p mongodb.url='mongodb://<user>:<pass>@host1:port1,host2:port2,host3:port3/admin?authSource=admin&replicaSet=rs0' \ -p table=test -threads 100 -p recordcount=100000 \ -p readproportion=0 -p updateproportion=1 -p insertproportion=0 \ -p operationcount=50000 -p fieldcount=500 -p writeallfields=true}}
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Updating many fields of a wide document (an object with a large number of sibling fields) is O(n^2) in the number of fields, because each targeted field is located with an independent linear mutablebson::Element::findFirstChildNamed() scan over the same sibling chain.

      This proposal adds a per-apply(), target-only field-name index so those repeated lookups become O(1), reducing the overall cost from O(n^2) to O. It is guarded by a runtime-tunable threshold (default off), only applies to object nodes, and does not change update semantics.

      Measured on a 3-node replica set with YCSB (100k docs, 5000 fields/doc), throughput improves by roughly 1.5x–11x across the tested lookup-cost-equivalent scenarios (larger updates benefit more), and the dominant CPU symbol findFirstChildNamed disappears from the profile.

        1. image-2026-07-21-21-53-59-436.png
          image-2026-07-21-21-53-59-436.png
          97 kB
        2. image-2026-07-21-21-54-10-312.png
          image-2026-07-21-21-54-10-312.png
          198 kB
        3. image-2026-07-21-21-54-40-112.png
          image-2026-07-21-21-54-40-112.png
          138 kB
        4. image-2026-07-21-21-54-58-940.png
          image-2026-07-21-21-54-58-940.png
          291 kB

            Assignee:
            Unassigned
            Reporter:
            y yz (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: