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).
- is related to
-
SERVER-35057 Notify oplog waiter after advancing the lastApplied timestamp
- Closed
-
SERVER-59776 50% regression in single multi-update
- Closed