Add cache stripe lock contention metric #12839
Open
+95
−71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds two new metrics to track cache lock contention:
proxy.process.cache.stripe.lock_contention- counts stripe mutex contentionproxy.process.cache.writer.lock_contention- counts writer VC mutex contention during read aggregationAlso available per-volume as
proxy.process.cache.volume_N.stripe.lock_contention.Background
When ATS is configured with more threads than cache volumes, threads contend heavily for the stripe mutex, causing throughput degradation. These metrics make contention visible so operators can tune their configuration.
Benchmark Results
Testing on a 16-core system with 100 cached URLs:
With only 1 volume, 16 threads is slower than 4 threads due to contention. Adding volumes eliminates the bottleneck.
Usage
Implementation
Stripe Lock Contention Call Sites (
VC_SCHED_LOCK_RETRY/VC_LOCK_RETRY_EVENT)All for
stripe->mutex:CacheRead.cc:
CacheVC.cc:
CacheWrite.cc:
Writer Lock Contention Call Site (
VC_SCHED_WRITER_LOCK_RETRY)For
write_vc->mutex(not stripe):CacheRead.cc:
Files Changed
P_CacheStats.h: Addstripe_lock_contentionandwriter_lock_contentioncountersCacheProcessor.cc: Register both metricsP_CacheInternal.h: Add metric increments to retry macros, addVC_SCHED_WRITER_LOCK_RETRY()CacheRead.cc: UseVC_SCHED_WRITER_LOCK_RETRY()for writer mutex case