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

Performance: Stats collection unitSize() does tcmalloc and free

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0, 8.0.0-rc5
    • Affects Version/s: 6.3.2, 4.4.29, 6.0.15, 7.0.8, 7.3.0, 8.1.0-rc0, 8.0.0-rc2
    • Component/s: None
    • Labels:
      None
    • Query Execution
    • Major Change
    • v8.0, v7.3, v7.0, v6.0, v5.0
    • QE 2024-04-29
    • 200

      An innocuous looking stats collection call from SERVER-51024 causes significant performance regression in microbenchmark Queries.FindProjectionThreeFields. The call is made for every document seen in run_aggregate.cpp getFirstBatch(). The issue is that the innocent-looking unitSize() call in observeOne() in resource_consumption_metrics.h has become very expensive since it was changed to return gDocumentUnitSizeBytes, which is an IDL-based server parameter and uses intrusive pointers, thus triggering a tcmalloc and free every time it is accessed.

      Changing gDocumentUnitSizeBytes to the constant 128, its default, in unitSize() results in a +20% performance gain in this benchmark.

      geert.bosch@mongodb.com advised that the stats parameters

      1. gDocumentUnitSizeBytes
      2. gIndexEntryUnitSizeBytes
      3. gTotalUnitWriteSizeBytes

      (defined in operation_resource_consumption.idl) no longer need to be tunable, so the fix is to remove these and replace them with their integer constant defaults. Additionally the computations involving these do not need to use floating point division.

            Assignee:
            kevin.cherkauer@mongodb.com Kevin Cherkauer
            Reporter:
            kevin.cherkauer@mongodb.com Kevin Cherkauer
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: