Skip to content

Improve AccumulatorCompiler generated code#16722

Merged
pettyjamesm merged 3 commits into
prestodb:masterfrom
pettyjamesm:improve-accumulator-compiler
Sep 24, 2021
Merged

Improve AccumulatorCompiler generated code#16722
pettyjamesm merged 3 commits into
prestodb:masterfrom
pettyjamesm:improve-accumulator-compiler

Conversation

@pettyjamesm

@pettyjamesm pettyjamesm commented Sep 9, 2021

Copy link
Copy Markdown
Contributor

Improves the AccumulatorCompilerGeneratedCode by

  • Using int field for maskChannel and inputChannel fields, instead of retaining a boxed Optional or List of Integer
  • Filtering RLE mask blocks of true into null before entering the input loop to bypass unnecessary mask checks
  • Checking for RLE false mask blocks before entering the addInput main loop

Benchmark results (note, this does not test the RLE mask handling scenarios):

== NO RELEASE NOTE ==

@mbasmanova

mbasmanova commented Sep 15, 2021

Copy link
Copy Markdown
Contributor

@jamesgpearce James, these are very nice optimizations, but I can't really read the code generation code. The benchmark results visualization is very cool. I'm curious how did you create it? The changes looks good, but I wonder whether there is sufficient testing. Have you done any additional testing beyond unit tests? If so, would you share what these are?

CC: @tdcmeehan @kaikalur @yuanzhanhku

@pettyjamesm

Copy link
Copy Markdown
Contributor Author

The benchmark results visualization is very cool. I'm curious how did you create it?

You can tell JMH to output results as JSON format, and those files can be parsed and displayed using jmh.morethan.io either by uploading the local file or by adding a ?sources=<url_one>,<url_two> query parameter (I uploaded mine as a github gist and to those URLs here).

The changes looks good, but I wonder whether there is sufficient testing. Have you done any additional testing beyond unit tests? If so, would you share what these are?

I added a test so that any distinct aggregations tests using AggregationTestUtils#distinctAggregation (called via AggregationTestUtils#assertAggregation) will test both RLE and non-RLE mode of distinct masks, but since I saw you were the last person to add changes to AccumulatorCompiler in #14123 that you might have a better sense about whether there were scenarios to test beyond the unit tests.

@mbasmanova

Copy link
Copy Markdown
Contributor

Thank you, James. We are consistently finding that deep changes in the engine like these are not getting sufficiently covered by unit tests as bugs come out when we run the verifier during release process or after deployment in production settings. Any chance you could run this change on some of the production workload you have access to? This would give us a bit more confidence that this change won't break things. That said, I feel the quality of this PR is high therefore I'm going to accept. I'll wait for you to decide whether you can do additional testing before merging.

@pettyjamesm pettyjamesm force-pushed the improve-accumulator-compiler branch 4 times, most recently from c9a01d1 to b1e8429 Compare September 17, 2021 16:19
Improves the AccumulatorCompilerGeneratedCode by
- Using an int for the maskChannel field as well as each inputChannel
  field required instead of retaining a boxed Optional or List of Integer
- Filtering RLE mask blocks of true into nulls before entering the input
  loop to bypass unnecessary mask checks
- Detecting RLE mask blocks of false and bypassing the addInput for loop
  if all positions are eliminated
@pettyjamesm pettyjamesm force-pushed the improve-accumulator-compiler branch from b1e8429 to 12e4ce7 Compare September 24, 2021 11:40
@pettyjamesm

Copy link
Copy Markdown
Contributor Author

This has been running in our test environment for a while now with no edge cases discovered and has also been merged into Trino at this point without incident reported there. Since I see other ongoing work in the area of aggregations and codegen, I'm going to merge once the rebased changes are green since it seems like letting this PR sit open longer is more likely to let incompatible changes creep in.

@pettyjamesm pettyjamesm merged commit a027b23 into prestodb:master Sep 24, 2021
@pettyjamesm pettyjamesm deleted the improve-accumulator-compiler branch September 24, 2021 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants