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

Reduce calls to the cappedInsertNotifier for the oplog

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.0.1, 6.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • v6.0, v5.3, v5.0
    • Repl 2022-04-18, Repl 2022-05-02, Repl 2022-05-16, Repl 2022-05-30, Repl 2022-06-13
    • 0

      When oplog visibility is in effect, there is no need to signal the oplog notifier on every insert; since the newly-inserted data isn't visible, any read threads will wake up, find no new data, and go back to sleep.

      Further, we also signal the oplog notifier when we move lastApplied. This is only necessary when we could be reading at lastApplied, which is only on secondaries (on primaries, the lastAppliedSnapshot may contain holes and is invalid). Thus we only need to signal at the end of a secondary applier batch, not at every lastApplied update.

      Notifying a condition variable is surprisingly expensive on Linux. If the condition variable is not being waited on, there's an uncontended mutex acquire and release (for condition_variable_any) and the signal itself; this is a few atomic operations. But if it is being waited on, there is system call overhead (futex_wake).

            Assignee:
            matthew.russotto@mongodb.com Matthew Russotto
            Reporter:
            matthew.russotto@mongodb.com Matthew Russotto
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: