Repository navigation
Parquet v3: add read back-pressure for the compressed prefetch stage #2977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ianton-ru
wants to merge
5
commits into
antalya-26.8
Choose a base branch
from
feature/antalya-26.8/parquet-prefetch-bandwidth-backpressure
base: antalya-26.8
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
189feba
Parquet v3: add read back-pressure for the compressed prefetch stage
UnamedRus 92921ad
Parquet v3: count back-pressure stalls and test the prefetch back-pre…
ianton-ru 129d266
Parquet v3: count back-pressure stalls only when a row group is actua…
ianton-ru 1b54da3
Parquet v3: describe the back-pressure measure as the bytes buffered …
ianton-ru facf670
Parquet v3: reject a negative `input_format_parquet_prefetch_bandwidt…
ianton-ru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
7 changes: 7 additions & 0 deletions
7
tests/queries/0_stateless/05818_parquet_prefetch_bandwidth_back_pressure.reference
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| -- back-pressure disabled (default) | ||
| 124999750000 10434925257862044929 500000 | ||
| -- back-pressure with a tiny target: same result, no hang | ||
| 124999750000 10434925257862044929 500000 | ||
| -- back-pressure engages only when enabled | ||
| 1 | ||
| 1 |
56 changes: 56 additions & 0 deletions
56
tests/queries/0_stateless/05818_parquet_prefetch_bandwidth_back_pressure.sh
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/usr/bin/env bash | ||
| # Tags: no-fasttest | ||
|
|
||
| CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
| # shellcheck source=../shell_config.sh | ||
| . "$CUR_DIR"/../shell_config.sh | ||
|
|
||
| USER_FILES_PATH=$($CLICKHOUSE_CLIENT_BINARY --query "select _path,_file from file('nonexist.txt', 'CSV', 'val1 char')" 2>&1 | grep Exception | awk '{gsub("/nonexist.txt","",$9); print $9}') | ||
| WORKING_DIR="${USER_FILES_PATH}/${CLICKHOUSE_TEST_UNIQUE_NAME}" | ||
| mkdir -p "${WORKING_DIR}" | ||
| DATA_FILE="${WORKING_DIR}/back_pressure.parquet" | ||
|
|
||
| # 500000 rows, 5000 rows per row group => 100 row groups, so that many row groups are waiting to be | ||
| # prefetched while a few are decoded. | ||
| ${CLICKHOUSE_CLIENT} -q " | ||
| INSERT INTO FUNCTION file('${DATA_FILE}', Parquet) | ||
| SELECT number AS k, toString(cityHash64(number)) AS s | ||
| FROM numbers(500000) | ||
| SETTINGS engine_file_truncate_on_insert = 1, output_format_parquet_row_group_size = 5000, | ||
| output_format_parquet_compression_method = 'none' | ||
| " | ||
|
|
||
| STRUCTURE="k UInt64, s String" | ||
| # A small memory budget keeps most row groups unscheduled at first. The sleep slows the consumer down, so | ||
| # that the scheduler runs again after the read throughput estimate has become available. | ||
| COMMON="input_format_parquet_use_native_reader_v3 = 1, max_threads = 4, input_format_parquet_memory_high_watermark = 4194304" | ||
|
|
||
| run() | ||
| { | ||
| ${CLICKHOUSE_CLIENT} --query_id="${CLICKHOUSE_TEST_UNIQUE_NAME}_$1" -q " | ||
| SELECT sum(k), sum(cityHash64(s)), count() | ||
| FROM file('${DATA_FILE}', Parquet, '${STRUCTURE}') | ||
| WHERE sleepEachRow(0.000003) = 0 | ||
| SETTINGS ${COMMON}, input_format_parquet_prefetch_bandwidth_hide_seconds = $2 | ||
| " | ||
| } | ||
|
|
||
| echo "-- back-pressure disabled (default)" | ||
| run off 0 | ||
| echo "-- back-pressure with a tiny target: same result, no hang" | ||
| run tiny 0.000001 | ||
|
|
||
| echo "-- back-pressure engages only when enabled" | ||
| ${CLICKHOUSE_CLIENT} -q " | ||
| SYSTEM FLUSH LOGS query_log; | ||
| SELECT ProfileEvents['ParquetPrefetchBackPressureStalls'] = 0 | ||
| FROM system.query_log | ||
| WHERE event_date >= yesterday() AND event_time >= now() - 600 | ||
| AND query_id = '${CLICKHOUSE_TEST_UNIQUE_NAME}_off' AND type = 'QueryFinish' AND current_database = currentDatabase(); | ||
| SELECT ProfileEvents['ParquetPrefetchBackPressureStalls'] > 0 | ||
| FROM system.query_log | ||
| WHERE event_date >= yesterday() AND event_time >= now() - 600 | ||
| AND query_id = '${CLICKHOUSE_TEST_UNIQUE_NAME}_tiny' AND type = 'QueryFinish' AND current_database = currentDatabase(); | ||
| " | ||
|
|
||
| rm -rf "${WORKING_DIR}" |
5 changes: 5 additions & 0 deletions
5
tests/queries/0_stateless/05819_parquet_prefetch_bandwidth_hide_seconds_validation.reference
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| -- valid values | ||
| 499500 1000 | ||
| 499500 1000 | ||
| -- negative value is rejected | ||
| input_format_parquet_prefetch_bandwidth_hide_seconds must be non-negative |
35 changes: 35 additions & 0 deletions
35
tests/queries/0_stateless/05819_parquet_prefetch_bandwidth_hide_seconds_validation.sh
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/usr/bin/env bash | ||
| # Tags: no-fasttest | ||
|
|
||
| CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
| # shellcheck source=../shell_config.sh | ||
| . "$CUR_DIR"/../shell_config.sh | ||
|
|
||
| USER_FILES_PATH=$($CLICKHOUSE_CLIENT_BINARY --query "select _path,_file from file('nonexist.txt', 'CSV', 'val1 char')" 2>&1 | grep Exception | awk '{gsub("/nonexist.txt","",$9); print $9}') | ||
| WORKING_DIR="${USER_FILES_PATH}/${CLICKHOUSE_TEST_UNIQUE_NAME}" | ||
| mkdir -p "${WORKING_DIR}" | ||
| DATA_FILE="${WORKING_DIR}/validation.parquet" | ||
|
|
||
| ${CLICKHOUSE_CLIENT} -q " | ||
| INSERT INTO FUNCTION file('${DATA_FILE}', Parquet) | ||
| SELECT number AS k FROM numbers(1000) | ||
| SETTINGS engine_file_truncate_on_insert = 1 | ||
| " | ||
|
|
||
| run() | ||
| { | ||
| ${CLICKHOUSE_CLIENT} -q " | ||
| SELECT sum(k), count() | ||
| FROM file('${DATA_FILE}', Parquet, 'k UInt64') | ||
| SETTINGS input_format_parquet_use_native_reader_v3 = 1, input_format_parquet_prefetch_bandwidth_hide_seconds = $1 | ||
| " 2>&1 | grep -o -m1 "input_format_parquet_prefetch_bandwidth_hide_seconds must be non-negative\|[0-9]* [0-9]*" | ||
| } | ||
|
|
||
| echo "-- valid values" | ||
| run 0 | ||
| run 0.5 | ||
|
|
||
| echo "-- negative value is rejected" | ||
| run -1 | ||
|
|
||
| rm -rf "${WORKING_DIR}" |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a plain scan without earlier bloom/index tasks, the first
ColumnDataPrefetchscheduling pass always sees unknown throughput:readFileMetaDatacallsPrefetcher::readSyncdirectly, whiletotal_bytes_readis updated only byrunTask. Since the limit is then computed once before the scheduling loop, that pass admits row groups up to the existing memory allowance—about 1.8 GiB with the default 4 GiB budget for one reader—even if reads complete while the loop runs. Files fitting in that initial allowance therefore receive no back-pressure at all, and larger files retain the full initial burst; the test hides this by reducing the watermark to 4 MiB and forcing a later scheduling pass. Add a bounded bootstrap policy or recompute the estimate while admitting the initial batch.Useful? React with 👍 / 👎.