Repository navigation
Use a page cache lookahead of one block for text index files read out of file order - #125770
Conversation
…one block The text index reads its dictionary blocks in the order of token cardinality, and its postings and positions token by token, so the reads jump forward and backward in the file. On a miss, `CachedInMemoryReadBufferFromFile` extends the read limit of the underlying buffer over up to `page_cache_lookahead_blocks` uncached blocks but fills only one, so for these files the next seek abandons the request with data still in flight. The remote connection then cannot be reused: an S3 HTTP connection is reset in `atConnectionDestroy` (`DiskConnectionsReset`), and a distributed cache connection is dropped. A text index search could open a new connection for almost every page cache miss. Open the dictionary, postings and positions streams of query-time readers with a lookahead of one block. The sparse index, which is read from the start, and the merge of text indexes, which reads sequentially, keep the normal lookahead, and so do the column streams of the query. The new setting `use_page_cache_lookahead_for_text_index` restores the normal lookahead for the text index streams. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [b1a5207] Summary: ✅
AI ReviewSummaryThe PR limits userspace page cache lookahead to one block for query-time text index dictionary, postings, and positions streams, reducing abandoned remote requests. Sparse-index reads, index merges, and column streams retain normal lookahead; Missing context / blind spots
Final Verdict✅ Approve — no code changes requested. Merge remains subject to completion of CI. |
The test runs `SYSTEM DROP PAGE CACHE`, which the style check requires to be `no-parallel`. A page cache drop from another test would also change the counts the test checks. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125770&sha=latest&name_0=PR PR: #125770 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The stateless servers in CI have no page cache: `page_cache_max_size` is 0 by default, and `tests/config` does not set it. So `05394_text_index_page_cache_lookahead_s3` read directly from S3, had no `PageCacheMisses`, and failed in all flaky check jobs. Check the same three queries in `test_userspace_page_cache`, whose server already has an S3 disk and a page cache, and delete the stateless test. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125770&sha=latest&name_0=PR PR: #125770 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…search `readAllPostingsForToken` reads every block of a token in file order, so with a lookahead of one block each page cache miss became a separate remote request. Its local stream now keeps the normal lookahead; the per-token cursor streams still read one block at a time. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nly patterns `analyzeDictionaryForPatterns` reads dictionary blocks in ascending ranges, in file order, so with a lookahead of one block each page cache miss became a separate remote request. The dictionary stream now keeps the normal lookahead when the condition has no search tokens; a condition with search tokens still reads one block at a time, because `analyzeDictionaryForTokens` visits the blocks in token-cardinality order. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units305 translation units recompiled, 3239 s compile time in total, 305 of them have a recent master baseline. |
…ex reads Reverts the normal lookahead for the whole posting-list reads of phrase search (`readAllPostingsForToken`) and for the dictionary of conditions with only patterns. These reads are in file order, but each list or range is followed by a seek to an unrelated offset, or the stream is dropped, so a longer lookahead abandons a request with data in flight at the end of every list or range. The same change for the exhaustive reads of `ReadFromTextIndexCount` gave one `DiskConnectionsReset` per token in `test_text_index_lookahead`. With one block, only lists or ranges longer than one page cost more requests, and those reuse the connection. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…akeTextIndexInputStream` Each comment at a call site now gives only the reason for its value, with the prefix `use_page_cache_lookahead: `. The mechanism is described once in `TextIndexUtils.h` and `makeTextIndexReaderSettings`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@CurtizJ could you please take a look. I know it seems a bit hacky, but a more complete solution would probably be setting exact ranges to read which is a bit more complex. |
…ndexInputStream` The overload no longer assumes its caller is the index merge, which reads every substream in file order. It now takes the same defaulted argument as the part overload. Co-Authored-By: Claude Opus 5.5 <[email protected]>
#127489 changed the default of `text_index_posting_list_codec` to `pfor`. The compressed postings take fewer page cache blocks, so the default query had only 83 page cache misses and the `misses >= 100` assertion failed in the merge queue. The test is about the lookahead, not the codec, so keep the postings uncompressed. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=gh-readonly-queue/master/pr-125770-3b3f22da1d188310dfaf55af6b993fa8477e7bf4&sha=6ba1096d6fd295909fd5b518f171b6578c0ec2dc&name_0=MergeQueueCI PR: #125770 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The text index reads its dictionary, postings and positions out of file order. On a page cache miss,
CachedInMemoryReadBufferFromFilerequests up topage_cache_lookahead_blocksblocks but fills only one, so the next seek abandons the request with data in flight. The remote connection then cannot be reused (S3:DiskConnectionsReset; distributed cache: the connection is dropped), so a text index search could open a new connection for almost every miss.Query-time readers now open these streams with a lookahead of one block. The sparse index, the merge of text indexes and the column streams keep the normal lookahead. The new setting
use_page_cache_lookahead_for_text_indexrestores it for the text index streams.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Text index searches through the userspace page cache no longer reset a remote connection on almost every cache miss: the text index files that are read out of file order now use a page cache lookahead of one block. The new setting
use_page_cache_lookahead_for_text_indexrestores the normal lookahead.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125770]
Version info
26.11.1.1279-master(included in26.11and later)