Repository navigation
Slow down use_skip_indexes_on_data_read = 1 - #106918
shankar-iyer wants to merge 3 commits into
Conversation
… read. Evaluate skip indexes before creating MergeTree readers so fully filtered parts do not load column marks, while keeping checks parallel across read threads. Co-authored-by: Cursor <[email protected]>
|
Workflow [PR], commit [35bc325] Summary: ❌
AI ReviewSummaryThis PR moves Missing context / blind spots
Findings
Tests
Final VerdictStatus: Minimum required actions: restore look-ahead prefetch scheduling for surviving prefetched-pool tasks, move skip-index task construction outside the parallel-replica pool mutexes, and add focused evidence for those scheduling paths. |
Prepare prefetched readers only after task selection so skip-index checks stay parallel across read threads. Co-authored-by: Cursor <[email protected]>
…runing. Reserve prefetch memory and reader slots only for tasks that survive skip-index filtering, so fully pruned parts do not block later remote prefetches. Co-authored-by: Cursor <[email protected]>
| if (!thread_task) | ||
| return nullptr; | ||
|
|
||
| preparePrefetchedReadersIfNeeded(*thread_task); |
There was a problem hiding this comment.
preparePrefetchedReadersIfNeeded now runs only for the task that getTask is about to return, and createTask immediately consumes that same future through readers_future->get. After removing startPrefetches and prefetch_queue, later tasks no longer have their readers and prefetchBeginOfRange queued while the current task is being read; each task starts its prefetch only when selected and then waits for it before returning. That breaks the prefetched read pool contract for remote reads and can turn the target workload into synchronous per-task prefetching.
Please keep the skip-index check outside the mutex, but still schedule surviving tasks ahead of consumption, for example with a queue of pending tasks after skip pruning and budget acquisition, or with per-thread look-ahead so task N+1 can prefetch while task N is read.
| params_, | ||
| context_) | ||
| context_, | ||
| std::move(index_build_context_)) |
There was a problem hiding this comment.
Passing index_build_context into MergeTreeReadPoolParallelReplicas makes createTask call shouldSkipPartRead, but getTask still holds mutex from the lock_guard through return createTask(...). partHasSelectedGranules can run skip/projection index reads via getOrBuildIndexReadResult, so one reader thread can serialize that storage/index work while every other parallel-replica reader waits on the pool mutex. This violates the PR contract that skip-index checks stay parallel across read threads; the same pattern exists in MergeTreeReadPoolParallelReplicasInOrder, where getTask also holds its mutex through createTask.
Please split range selection from task construction and call createTask after releasing the mutex in both parallel-replica pools.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 233/250 (93.20%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 13 line(s) · Uncovered code |
|
Nice! I think this is very similar to what I'm trying to do in #103117. My PR is specific to projection indexes: once the projection bitmap exists, it converts that bitmap to This PR looks more general, evaluating all the skip indexes per part and then skipping instantiating readers for the parts that are empty. For the parts that survive this check, the full range of marks is still loaded, though. I wonder if there's a way to combine the PRs neatly, so the shared abstraction returns
Then projection bitmaps, text-index filters, and ordinary deferred skip indexes with What do you think? I don't think this necessarily needs to happen all in this PR, but maybe it's worth implementing in follow-up PRs? I'd be happy to help contribute these changes (like my above PR) with some help in code review. |
|
Hey @EmeraldShift I will take a look at the PR.
Is the point that if only 1 or 2 granules are needed from a I will be closing this PR. |
|
Closing this PR - I just needed gating of |
I'm not sure if #106662 covers this: it sounds like that PR is about necesasry block-based compression fetching a few more MiB than necessary from object storage. In my case I have a projection index like |
Change : With
use_skip_indexes_on_data_read = 1, evaluate skip indexes before instantiatingMergeTreereaders so that fully filteredpartsdo not load column marks (or prefetch column data), while keeping skip index checks parallel across read threads.Note that the essential identity of
use_skip_indexes_on_data_read = 1is still maintained. Data read of a selectedpartwill begin immediately when it's skip index filtering is complete.Currently, take a case where PK filtering has resulted in 1000 parts and skip index filtering is deferred to read time with
use_skip_indexes_on_data_read = 1. The column readers of the 1000 parts will immediately start reading their marks etc and cause significant load on the thread pool / storage. Skip Index filtering may finally find only 20partsto be read.Changelog category (leave one):