Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3328

Excessive memory allocation due to unwrapping of updates in bulk ops

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.11.0
    • Affects Version/s: 3.6.0, 3.7.0, 3.8.0, 3.9.0, 3.10.0
    • Component/s: Write Operations
    • None
    • Fully Compatible

      It looks like the changes inĀ 332ffc78538b36db880c94836d82276f5e5d9296 introduced a call to isEmpty() on the update document, to throw an illegal arg exception if the update document is empty.

      However, when used with BsonDocumentWrapper, the call to isEmpty() causes the wrapped document to be unwrapped, just to check for emptiness. This causes many unnecessary allocations when unwrapping update documents of any size.

      Removing this call saves about approx ~80% GC'd allocations for a comparable volume of writes, as illustrated in the attached screenshot comparing two JProfiler snapshots. On the left is the version w/o the check, on the right is the current code w/ the check.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            oleg@evergage.com Oleg Rekutin
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: