masaori335 opened a new pull request, #13840:
URL: https://github.com/apache/trafficserver/pull/13840
# Motivation
I have been experimenting with replacing the stripe mutex with a
reader-writer lock, hazard pointers, or RCU,
so that cache lookups can run concurrently. Every attempt hit the same
obstacle: `Directory::probe()` looks
like a lookup, but it deletes every stale entry it walks past. That makes
every lookup a directory writer, so
it needs exclusive access.
Other readers can see those writes. A lookup marks the directory dirty. When
the stale entry is a bucket head,
`delete_entry()` moves the next entry into the head slot, which can
invalidate another reader's
`last_collision` cursor.
# Approach
Make `probe()` a pure reader. Stale entries are left to the writers that
already collect them:
`Directory::cleanup()` at every cache cycle wrap, and `freelist_clean()`
when a segment's free list runs out.
`freelist_clean()` reclaims stale entries before it purges any live ones.
# Trade-off
Stale entries now hold directory slots until the next wrap. `probe()` only
ever reclaimed the stale entries of
keys that were looked up again, so the extra retention is bounded by those.
On the production caches we
checked, directory occupancy peaks well below half of capacity, so the extra
retention fits easily. Where it
doesn't, `freelist_clean()` reclaims the stale entries first.
# Visible changes
- **`proxy.process.cache.direntries.used` (global and per-volume) counts
stale entries until they are reclaimed.**
It now climbs higher through a cache cycle and drops at each wrap.
- **The `cache_dir_remove_invalid` USDT probe is removed.** `probe()` was
its only emission site.
# Testing
- New `test_CacheDir` cases:
- `probe()` leaves a stale entry in place, and `clean_segment()` reclaims
it.
- With a stale entry ahead of a live one for the same key, `probe()`
returns the live entry, and resuming
from it returns no further match rather than restarting from the bucket
head.
- The `ctest` cache suite passes.
# Follow-up
- Make the directory read path const-enforced, so a reader that mutates an
entry fails to compile (stacked on
this PR).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]