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

Improved parallel DecompressChunk worker selection #5870

Merged
merged 1 commit into from
Aug 10, 2023

Conversation

jnidzwetzki
Copy link
Contributor

@jnidzwetzki jnidzwetzki commented Jul 12, 2023

This PR improves the way the number of parallel workers for the DecompressChunk node are calculated. Since
1a93c2d, no partial paths for small chunks are generated, which could cause a fallback to a sequential plan and a performance regression. This patch ensures that a partial path is created again to get the 2.11.x behavior back.


Disable-check: force-changelog-file


Benchmarks

Tsbench against the last commit before this PR: https://grafana.ops.savannah-dev.timescale.com/d/NdmLnOk4z/compare-benchmark-runs?orgId=1&var-branch=All&var-run1=2549&var-run2=2551&var-threshold=0.02

Tsbench against 2.11.1 (a version without the commit 1a93c2d): https://grafana.ops.savannah-dev.timescale.com/d/NdmLnOk4z/compare-benchmark-runs?orgId=1&var-branch=All&var-run1=2514&var-run2=2551&var-threshold=0.02

Note: Disabling parallel plans for some queries might be beneficial. For example, when ht_chunk_compressed_2k is processed. Using this table, we have a lot of small chunks, and we have a huge overhead by the parallel logic. Here, we see some regression compared to the last commit but almost the same execution times as for 2.11.1.

Planner regression

Another result from benchmarking: it seems we have some kind of planner regression introduced in ecc1b7b. It is hidden on the tsbench dashboards due to some missing commits in tsbench and the fact this particular query becomes faster when it is executed sequentially. So, we have the planner regression which is compensated by the sequentially executed query. This should be addressed in a follow-up PR.

Commit ecc1b7b

tsbench=#  explain (verbose, analyze) SELECT * FROM ht_chunk_partially_compressed_2k WHERE device = 3 ORDER BY time, device DESC LIMIT 1;

 Planning Time: 1399.066 ms
 Execution Time: 674.978 ms

Before (d6030a3)

tsbench=#  explain (verbose, analyze) SELECT * FROM ht_chunk_partially_compressed_2k WHERE device = 3 ORDER BY time, device DESC LIMIT 1;

 Planning Time: 894.385 ms
 Execution Time: 717.762 ms

Differential Flame Graphs

Differential Flame Graphs for the query and the commits d6030a3 and ecc1b7b

diff

Tsbench run

https://grafana.ops.savannah-dev.timescale.com/d/NdmLnOk4z/compare-benchmark-runs?orgId=1&var-branch=main&var-run1=2620&var-run2=2621&var-threshold=0.02

@jnidzwetzki jnidzwetzki added force-auto-backport Automatically backport this PR or fix of this issue, even if it's not marked as "bug" compression labels Jul 12, 2023
@jnidzwetzki jnidzwetzki force-pushed the parallel_worker branch 3 times, most recently from e248784 to 267a239 Compare July 12, 2023 12:10
@codecov
Copy link

codecov bot commented Jul 12, 2023

Codecov Report

Merging #5870 (8600266) into main (2eb0a38) will increase coverage by 0.01%.
Report is 8 commits behind head on main.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #5870      +/-   ##
==========================================
+ Coverage   87.08%   87.09%   +0.01%     
==========================================
  Files         243      243              
  Lines       55917    55877      -40     
  Branches    12377    12359      -18     
==========================================
- Hits        48694    48666      -28     
+ Misses       4894     4858      -36     
- Partials     2329     2353      +24     
Files Changed Coverage Δ
src/import/allpaths.c 73.64% <ø> (-0.39%) ⬇️
tsl/src/nodes/decompress_chunk/decompress_chunk.c 89.91% <100.00%> (+0.44%) ⬆️

... and 36 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jnidzwetzki jnidzwetzki force-pushed the parallel_worker branch 13 times, most recently from 6054cd3 to 2122b26 Compare July 12, 2023 19:20
@jnidzwetzki jnidzwetzki removed the force-auto-backport Automatically backport this PR or fix of this issue, even if it's not marked as "bug" label Jul 12, 2023
@jnidzwetzki jnidzwetzki force-pushed the parallel_worker branch 2 times, most recently from 65d1a9b to 023c494 Compare July 13, 2023 07:17
@@ -2,7 +2,7 @@
-- Please see the included NOTICE for copyright information and
-- LICENSE-APACHE for a copy of the license.

SELECT * FROM compress ORDER BY time DESC, small_cardinality;
SELECT * FROM compress ORDER BY time DESC, small_cardinality, large_cardinality, some_double, some_int, some_custom, some_bool;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test output was not deterministic so far.

@jnidzwetzki jnidzwetzki marked this pull request as ready for review July 13, 2023 14:35
@github-actions
Copy link

@RafiaSabih, @fabriziomello: please review this pull request.

Powered by pull-review

@@ -1572,7 +1572,23 @@ create_compressed_scan_paths(PlannerInfo *root, RelOptInfo *compressed_rel, Comp

/* create parallel scan path */
if (compressed_rel->consider_parallel)
ts_create_plain_partial_paths(root, compressed_rel);
{
Copy link
Member

Choose a reason for hiding this comment

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

Since this is the only caller for ts_create_plain_partial_paths we should either move the code into that function or get rid of the function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The function is still called in set_plain_rel_pathlist(). However, it is used only in non-TSL code. So, I removed the export of the function.

Comment on lines 93 to 95
static void
create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
{
Copy link
Member

Choose a reason for hiding this comment

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

This is a matter of taste, but I would still leave the ts_ prefix so that it's harder to confuse with grep/go to definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed back to ts_create_plain_partial_paths as suggested.

@@ -17,7 +17,7 @@ WHERE
hypertable.table_name = 'compress'
AND chunk.compressed_chunk_id IS NULL;

SELECT * FROM compress ORDER BY time DESC, small_cardinality;
SELECT * FROM compress ORDER BY time DESC, small_cardinality, large_cardinality, some_double, some_int, some_custom, some_bool;
Copy link
Member

Choose a reason for hiding this comment

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

ORDER BY compress would order by all columns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have to use the same ordering as the existing up/downgrade tests to generate the same output. Otherwise, the tests will fail. Therefore, we need an ordering of time DESC and large_cardinality ASC. I think that is not possible with the proposed change.

@shhnwz
Copy link
Contributor

shhnwz commented Aug 9, 2023

@jnidzwetzki ,
Please rebase the branch, last week considerable changes went into decompress code path.

This PR improves the way the number of parallel workers for the
DecompressChunk node are calculated. Since
1a93c2d, no partial paths for small
relations are generated, which could cause a fallback to a sequential
plan and a performance regression. This patch ensures that for all
relations, a partial path is created again.
@jnidzwetzki
Copy link
Contributor Author

@shhnwz The PR is now rebased

Copy link
Contributor

@shhnwz shhnwz left a comment

Choose a reason for hiding this comment

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

Looks Good To Me.

@jnidzwetzki jnidzwetzki enabled auto-merge (rebase) August 10, 2023 09:57
@jnidzwetzki jnidzwetzki merged commit 9a2dfbf into timescale:main Aug 10, 2023
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants