Skip to content
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

Support orc filter push down (file + stripe + rowgroup level) #55330

Merged
merged 36 commits into from Oct 24, 2023

Conversation

taiyang-li
Copy link
Contributor

@taiyang-li taiyang-li commented Oct 8, 2023

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Support orc filter push down (rowgroup level)

related pr of contrib/orc: ClickHouse/orc#11

@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added pr-performance Pull request with some performance improvements submodule changed At least one submodule changed in this PR. labels Oct 8, 2023
@robot-clickhouse-ci-1
Copy link
Contributor

robot-clickhouse-ci-1 commented Oct 8, 2023

This is an automated comment for commit ef4b5d5 with description of existing statuses. It's updated for the latest CI running

❌ Click here to open a full report in a separate page

Successful checks
Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help✅ success
ClickHouse build checkBuilds ClickHouse in various configurations for use in further steps. You have to fix the builds that fail. Build logs often has enough information to fix the error, but you might have to reproduce the failure locally. The cmake options can be found in the build log, grepping for cmake. Use these options and follow the general build process✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker image for serversThe check to build and optionally push the mentioned image to docker hub✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integrational tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc✅ success
Install packagesChecks that the built packages are installable in a clear environment✅ success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ success
Mergeable CheckChecks if all other necessary checks are successful✅ success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests✅ success
Push to DockerhubThe check for building and pushing the CI related docker images to docker hub✅ success
SQLTestThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
SQLancerFuzzing tests that detect logical bugs with SQLancer tool✅ success
SqllogicRun clickhouse on the sqllogic test set against sqlite and checks that all statements are passed✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Style CheckRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success
Unit testsRuns the unit tests for different release types✅ success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts✅ success
Check nameDescriptionStatus
CI runningA meta-check that indicates the running CI. Normally, it's in success or pending state. The failed status indicates some problems with the PR⏳ pending
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors❌ failure

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 8, 2023
@taiyang-li taiyang-li marked this pull request as ready for review October 9, 2023 10:52
@taiyang-li
Copy link
Contributor Author

@alexey-milovidov can you review it, thanks!

@al13n321 al13n321 self-assigned this Oct 10, 2023
Copy link
Member

@al13n321 al13n321 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for the SourceWithKeyCondition refactoring!

Please add a test and remove the leftover debug logging (once you don't need it).

@taiyang-li
Copy link
Contributor Author

@al13n321 can you also review this related pr: ClickHouse/orc#11

@taiyang-li
Copy link
Contributor Author

taiyang-li commented Oct 13, 2023

Generating orc file

echo "select number as a, cast(number as String) as b from numbers(100000000) format ORC"  | clickhouse-client > seq.orc 

First test was improved by 8.7x:

Query: select a % 10, length(b) % 10, count(1) from file('seq.orc') where a > 90000000 group by a % 10, length(b) % 10

Without orc filter push down(set input_format_orc_filter_push_down = false)

10 rows in set. Elapsed: 2.086 sec. Processed 100.00 million rows, 791.82 MB (47.93 million rows/s., 379.55 MB/s.)
Peak memory usage: 15.29 MiB.

10 rows in set. Elapsed: 2.187 sec. Processed 100.00 million rows, 791.82 MB (45.72 million rows/s., 362.02 MB/s.)
Peak memory usage: 16.54 MiB.

10 rows in set. Elapsed: 2.143 sec. Processed 100.00 million rows, 791.82 MB (46.67 million rows/s., 369.57 MB/s.)
Peak memory usage: 14.39 MiB.

With orc filter push down(set input_format_orc_filter_push_down = true)

10 rows in set. Elapsed: 0.241 sec. Processed 10.00 million rows, 80.33 MB (41.56 million rows/s., 333.68 MB/s.)
Peak memory usage: 14.89 MiB.

10 rows in set. Elapsed: 0.238 sec. Processed 10.00 million rows, 80.33 MB (42.06 million rows/s., 337.68 MB/s.)
Peak memory usage: 14.83 MiB.

10 rows in set. Elapsed: 0.243 sec. Processed 10.00 million rows, 80.33 MB (41.24 million rows/s., 331.16 MB/s.)
Peak memory usage: 16.42 MiB.

Second test was improved by 117x

Query: select a % 10, length(b) % 10, count(1) from file('seq.orc') where a in (90000000, 1000) group by a % 10, length(b) % 10

Without orc filter push down(set input_format_orc_filter_push_down = false)

2 rows in set. Elapsed: 2.182 sec. Processed 100.00 million rows, 791.82 MB (45.84 million rows/s., 362.95 MB/s.)
Peak memory usage: 8.19 MiB.

2 rows in set. Elapsed: 2.175 sec. Processed 100.00 million rows, 791.82 MB (45.99 million rows/s., 364.14 MB/s.)
Peak memory usage: 8.20 MiB.

2 rows in set. Elapsed: 2.118 sec. Processed 100.00 million rows, 791.82 MB (47.21 million rows/s., 373.83 MB/s.)
Peak memory usage: 8.25 MiB.

With orc filter push down(set input_format_orc_filter_push_down = true)

2 rows in set. Elapsed: 0.025 sec. Processed 20.00 thousand rows, 149.44 KB (798.89 thousand rows/s., 5.97 MB/s.)
Peak memory usage: 758.29 KiB.

2 rows in set. Elapsed: 0.023 sec. Processed 20.00 thousand rows, 149.44 KB (882.51 thousand rows/s., 6.59 MB/s.)
Peak memory usage: 754.80 KiB.

2 rows in set. Elapsed: 0.018 sec. Processed 20.00 thousand rows, 149.44 KB (1.09 million rows/s., 8.15 MB/s.)
Peak memory usage: 757.79 KiB.

@al13n321
Copy link
Member

Lgtm, now just to figure out what to do with the orc PR (see comment there).

@al13n321
Copy link
Member

I can't figure out why new perf test orc_filter_push_down.xml failed in https://s3.amazonaws.com/clickhouse-test-reports/55330/de22fdcaea2e12c96f300e95f59beba84401712d/performance_comparison_[1_4]/report.html#run-errors @al13n321 need you help?

Maybe it's just from removing inline from Range::equals()? Looks like the parallel_index test does a few million Field comparisons (index granularity: 2, rows: 1M, WHERE has 6 equalities) and got slower by 100ms. That's on the order of 10 ns per Field comparison - kind of the right order of magnitude for function call overhead. Try making it inline again?

(If that's correct, I'm surprised that a simple function call overhead is so significant compared to all the Field visitor stuff and the index stuff and KeyCondition etc.)

@taiyang-li
Copy link
Contributor Author

But why perf test orc_filter_push_down has error:
image

@al13n321
Copy link
Member

The error is: Unknown setting input_format_orc_filter_push_down (from "Test output" at the bottom of the report page). Probably when running clickhouse without this PR (for the "old" side of the comparison). Maybe remove the settings input_format_orc_filter_push_down = 1 from the query. (Then we'll get a "regression" if the default value of that setting is changed in future, but then the PR that changes is can just add the settings input_format_orc_filter_push_down = 1 to the test again).

@@ -312,6 +797,9 @@ Chunk NativeORCBlockInputFormat::generate()
if (is_stopped)
return {};

/// TODO: figure out why reuse batch would cause asan fatals in https://s3.amazonaws.com/clickhouse-test-reports/55330/be39d23af2d7e27f5ec7f168947cf75aeaabf674/stateless_tests__asan__[4_4].html
/// Not sure if it is a false positive case. Notice that reusing batch will speed up reading ORC by 1.15x.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why asan fatals appear if batch is reused. Maybe it is a false positive ? @al13n321

@taiyang-li
Copy link
Contributor Author

taiyang-li commented Oct 20, 2023

@taiyang-li
Copy link
Contributor Author

image

It is faster after using orc filter push down feature.

@taiyang-li
Copy link
Contributor Author

taiyang-li commented Oct 23, 2023

@al13n321 do you think it is ok to merge this pr now.

@al13n321
Copy link
Member

al13n321 commented Oct 24, 2023

@taiyang-li
Copy link
Contributor Author

@taiyang-li
Copy link
Contributor Author

@canhld94
Copy link
Contributor

canhld94 commented Nov 2, 2023

This PR create a dangling commit in orc submodule.

@alexey-milovidov
Copy link
Member

@taiyang-li, according the test result it works even better on AArch64, but I don't know why: https://s3.amazonaws.com/clickhouse-test-reports/58061/7f170575229e41ba73102d6d7fb3718d04c604b8/stateless_tests__aarch64_.html

Quite soon, we will not allow any tests without AArch64: #58061

@taiyang-li
Copy link
Contributor Author

@taiyang-li, according the test result it works even better on AArch64, but I don't know why: https://s3.amazonaws.com/clickhouse-test-reports/58061/7f170575229e41ba73102d6d7fb3718d04c604b8/stateless_tests__aarch64_.html

Quite soon, we will not allow any tests without AArch64: #58061

Interesting, I'll see.

@taiyang-li
Copy link
Contributor Author

@alexey-milovidov sorry, I don't have any develop environment with AArch64. Could you add set input_format_orc_filter_push_down = false in tests/queries/0_stateless/02892_orc_filter_pushdown.sql, and test if outputs are different on X86-64 and AArch64? If yes, then the issue maybe related to ORC filter push down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can be tested Allows running workflows for external contributors pr-performance Pull request with some performance improvements submodule changed At least one submodule changed in this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants