Skip to content

CASSANDRA-21632: Bound and chunk the BTI partition index preload (for 6.0) - #5091

Open
aviau wants to merge 1 commit into
apache:cassandra-6.0from
aviau:bti-preload-chunked-60
Open

CASSANDRA-21632: Bound and chunk the BTI partition index preload (for 6.0)#5091
aviau wants to merge 1 commit into
apache:cassandra-6.0from
aviau:bti-preload-chunked-60

Conversation

@aviau

@aviau aviau commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

As requested by @driftx, this is the same as #5089 but for cassandra-6.0.

@aviau aviau changed the title Bound and chunk the BTI partition index preload CASSANDRA-21632: Bound and chunk the BTI partition index preload (for 6.0) Sep 2, 2026
Comment thread src/java/org/apache/cassandra/io/sstable/format/bti/PartitionIndex.java Outdated
Opening a BTI SSTable whose bloom filter is uninformative warms the whole
Partitions.db, one byte per page through a reader that follows disk_access_mode. That
costs one pread or one readahead-bounded page fault per page: on a 309 GiB index,
81.1M reads at 50 MiB/s regardless of access mode. It also warms far more than the
available page cache can hold.

Add cassandra.bti.partition_index_preload_size to bound how much is warmed. The tail
is warmed because the trie is written bottom-up, so the upper levels traversed by
every lookup are at the end of the file, while the bulk at the front is leaf pages
that a lookup reads one of.

The property takes a human-readable size, e.g. 512MiB. 0B skips warming entirely,
which was not previously possible: preload is enabled whenever the bloom filter is
uninformative, so the only way to avoid it was to lower bloom_filter_fp_chance below
1.0. A negative value warms the whole index and is the default, so behaviour is
unchanged unless the property is set.

Also read the preload in chunks: touching one byte per page costs a pread or a page
fault per page. Read it in 1 MiB positioned reads on the channel instead, which are
unaffected by disk_access_mode; page cache is shared between the buffered and mapped
views of a file, so a mapped lookup still finds the data resident.

The trade-offs: the whole range is copied into userspace rather than one byte per
page, and under a mapped mode the first lookup takes a minor fault the walk had
already resolved. Under disk_access_mode: standard the warm no longer populates the
chunk cache, nor evicts it; lookups fill it on first touch instead.

Assisted-by: Claude Code:claude-opus-5

patch by Alexandre Viau; reviewed by TBD for CASSANDRA-21632
@aviau
aviau force-pushed the bti-preload-chunked-60 branch from 996359b to 5c179c3 Compare September 2, 2026 12:40
@aviau
aviau requested a review from driftx September 2, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants