Skip zero-valued atomic updates in TicketingSystem::finalizeOperationStats

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Product Performance
    • WR Prioritized list
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Problem

      finalizeOperationStats accounts for 0.53% flat CPU (0.68% cumulative) on the 95%-read path (CurOp::completeAndLogOperationTicketingSystem::finalizeOperationStatsExecutionAdmissionContext::finalizeStats). For every completed operation, the function unconditionally executes ~40 fetchAndAddRelaxed operations on shared global AggregatedExecutionStats counters. On the 95% read path, the vast majority of these atomics add zero — write-path counters (writeShort, writeLong, writeDelinquency) are always zero for reads, and long-running counters (longRunning, readLong) are always zero for short-running reads. On ARM64 (Graviton), each atomic RMW instruction generates exclusive-store traffic on the cache line regardless of the value added, causing unnecessary cache-line bouncing across all 128 worker threads sharing the _operationStats structure.

      Solution

      Guard each accumulation block in finalizeOperationStats with a cheap per-call check before touching the shared global counters. Each guard tests a single loadRelaxed field from the per-operation snapshot that serves as a provably complete proxy for "all fields in this group are zero" — for example, totalOpsFinished == 0 for the finalized-stats group and totalAdmissions == 0 for the per-acquisition groups. When all source fields are zero, the entire AggregatedExecutionStats::operator+= call (and any nested incrementDelinquencyStats call) is skipped entirely, eliminating the unnecessary cache-line writes without changing observable behavior.

            Assignee:
            Jawwad Asghar
            Reporter:
            Jawwad Asghar
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: