Storage: Improve small partition table read performance by limit concurrency (#10489)#10500
Merged
ti-chi-bot[bot] merged 1 commit intopingcap:release-nextgen-20251011from Oct 23, 2025
Conversation
…urrency (pingcap#10489) close pingcap#10487 * Limit the number of source ops by num of segment task * 4 in function `DeltaMergeStore::read`. In order to reduce concurrency overhead and let PartitionTableScan with small partitions that only contains 1~2 segments can schedule more segment read tasks in parallel. - For large partition, the storage layer still generate `num_streams` * `UnorderedSourceOp`, the behavior is the same as before. - For small partition, the storage layer only generate segment task * 4 * `UnorderedSourceOp`. And `ConcatBuilderPool` reorg the source ops and read the data from multiple partitions in parallel * Introduce `DMReadOptions` and reduce the complexity of adding has_multiple_partitions from compute layer to storage layer. * Add active_segment_limit, peak_active_segments, block_slot_limit, peak_blocks_in_queue when `SegmentReadTaskPool` finished Signed-off-by: JaySon-Huang <tshent@qq.com>
12 tasks
JaySon-Huang
approved these changes
Oct 23, 2025
Lloyd-Pottiger
approved these changes
Oct 23, 2025
Contributor
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JaySon-Huang, Lloyd-Pottiger The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Contributor
[LGTM Timeline notifier]Timeline:
|
Contributor
|
/test pull-unit-next-gen |
8ac2a96
into
pingcap:release-nextgen-20251011
4 checks passed
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.
This is an automated cherry-pick of #10489
What problem does this PR solve?
Issue Number: close #10487
Problem Summary:
If a PartitionTableScan involve many partition but each partition only have 1 segment. Then
DeltaMergeStore::readwill generatenum_partitions*num_streams*UnorderedSourceOp. Because there is only 1 segment,SegmentReadTaskPoolwill only have 1 concurrency for reading data from disk.tiflash/dbms/src/Storages/DeltaMerge/DeltaMergeStore.cpp
Lines 1421 to 1454 in 80e1927
In order to avoid OOM issue when running queries on large PartitionTableScan (#8507),
MultiplexInputStreamandConcatBuilderPoolwill process streams/source ops of partition tables one by one.tiflash/dbms/src/Operators/ConcatSourceOp.h
Lines 190 to 199 in 80e1927
So there is only 1 concurrency for storage layer scanning data from 1 partition, and all compute thread wait for the blocks read from the partition. Only after the current partition finish reading, compute thread will call streams/source ops from the next partition. It result to the PartitionTableScan performance degrade along with the number of partitions, which is not expected.
What is changed and how it works?
Main logic changes is this piece of code: https://github.com/pingcap/tiflash/pull/10489/files#diff-22b900e9e8020dc835612316f3bf151cae28b621bfac64d6a22b377d062f4b7eR1419-R1435
The source ops generated by each partition will be added to
ConcatBuilderPoolthat wrap intoConcatSourceOp. Consider num_stream == 8.In the master, each partition will generate final_num_stream * UnorderedSourceOp. And ConcatBuilderPool will generate 8 ConcatSourceOp by
After this PR, ConcatBuilderPool will generate 8 ConcatSourceOp by
So after this PR, compute layer read part-1 and part-2 in parallel
Manual test
manual test of small partition table scan performance as described in #10487 (comment)
Check List
Tests
See the manual test describe above
Side effects
Documentation
Release note