CASSANDRA-21094 Advise sequential access on descriptors owned by bulk SSTable scans and streaming - #5133
Open
cheeeee wants to merge 1 commit into
Open
CASSANDRA-21094 Advise sequential access on descriptors owned by bulk SSTable scans and streaming#5133cheeeee wants to merge 1 commit into
cheeeee wants to merge 1 commit into
Conversation
cheeeee
force-pushed
the
CASSANDRA-21094-trunk
branch
from
September 10, 2026 01:25
13a50f6 to
4fe4da7
Compare
Keep existing mmap regions and direct-I/O fallback semantics. Buffered scans use independently owned uncached handles so closing a scan does not evict foreground chunks. Advise descriptors actually used by buffered scans and streaming reads; leave shared mmap and direct readers unadvised. CASSANDRA-21094 Generated-by: Claude (Anthropic)
cheeeee
force-pushed
the
CASSANDRA-21094-trunk
branch
from
September 11, 2026 22:50
4fe4da7 to
f728cc5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
CASSANDRA-21094: compaction and streaming read SSTables sequentially but never tell the kernel, so
readahead starts at its default window and ramps up heuristically.
posix_fadvise(POSIX_FADV_SEQUENTIAL) doubles the readahead window of the open file description it is
called on. It therefore has to be issued on a descriptor that only the sequential reader uses; the
SSTable's shared data handle also serves point reads and must not be advised.
Changes:
(compaction, cleanup, scrub, offline tools). When the effective access mode is buffered (standard),
it opens a private FileHandle for the scan, advises its descriptor as sequential, and closes it with
the reader. The private handle does not share the SSTable's chunk cache or the writer's mmapped
regions cache, so opening and closing it cannot invalidate cached chunks for other readers. Under
mmap the file is not read through the descriptor's read()/readahead path and under direct I/O the
page cache is bypassed, so in both cases the shared handle is reused unchanged and no advice is
issued.
shared handle and is never advised.
each open their own channel per transfer and advise it, but only when a single section spans the
whole file, since readahead past a section end would read bytes that are not sent.
Cassandra also uses as the fallback for unrecognised systems); a failure is logged at WARN with
rate limiting and is otherwise ignored, as for trySkipCache. No-op on macOS and AIX.
Behaviour change: buffered bulk scans no longer read through the shared chunk cache. They neither
warm it nor evict its entries; compaction reads previously did both.
Testing:
leaves the shared handle's cached chunks in place; a bulk scan of a freshly flushed SSTable under
mmap works; direct mode on an uncompressed table falls back to the shared handle; user range reads
are never advised; plus the existing reuse/close/leak cases.
length 0 and POSIX_FADV_SEQUENTIAL on the given descriptor.
the pages resident beyond the read position are 32 without advice and 96 with it (mincore); reading
through a second, unadvised descriptor of the same file after advising the first shows 32, i.e. the
advice does not leak between open file descriptions.
quantified here.
CASSANDRA-21094