Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-97094

Optimize update() document diffing algorithm to do fewer allocations

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution

      The doc_diff calculator is used on the pipeline update path for computing a diff between the update's pre-image and post-image. This code does roughly one allocation per diff-node, in order to build a diff tree.

      This is rather inefficient and we should look into ways of avoiding the allocations. Namely,

      • Restructure the code to avoid creating a tree at all. This may not be possible but is worth a look.
      • Allocate space for the tree nodes all at once. Essentially a bump allocator. There may also be generic infrastructure for this type of pattern that already exists, and if so, we should try to use it.
        • This should be a good candidate for a bump allocator since we create the diff tree, generate a BSON from it, and then throw the diff tree away. The lifetime of the diff tree is relatively short and we dispose of the whole thing at once.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ian.boros@mongodb.com Ian Boros
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: