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

Update grouping table to sample window size as well #24388

Merged
merged 1 commit into from Dec 8, 2022

Conversation

lukecwik
Copy link
Member

@lukecwik lukecwik commented Nov 29, 2022

The existing implementation only sampled the key/accumulator size but always measured the size of the window. Note the 50-75% improvement for non-globally windowed accumulation.

There are also some trivial reductions hashCode/equality since we know that certain types are always non-null.

Before

Benchmark                                                 (distribution)  (globallyWindowed)   Mode  Cnt   Score   Error  Units 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine         uniform                true  thrpt   15  12.775 ± 0.640  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine         uniform               false  thrpt   15   6.047 ± 0.535  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          normal                true  thrpt   15   7.148 ± 0.473  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          normal               false  thrpt   15   4.233 ± 0.239  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          hotKey                true  thrpt   15  13.894 ± 0.649  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          hotKey               false  thrpt   15   6.708 ± 0.375  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine      uniqueKeys                true  thrpt   15   2.286 ± 0.115  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine      uniqueKeys               false  thrpt   15   1.765 ± 0.064  ops/s

After

Benchmark                                                 (distribution)  (globallyWindowed)   Mode  Cnt   Score   Error  Units 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine         uniform                true  thrpt   15  13.399 ± 0.241  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine         uniform               false  thrpt   15  11.522 ± 1.120  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          normal                true  thrpt   15   7.186 ± 0.123  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          normal               false  thrpt   15   6.578 ± 0.161  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          hotKey                true  thrpt   15  13.467 ± 0.562  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          hotKey               false  thrpt   15   9.704 ± 0.866  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine      uniqueKeys                true  thrpt   15   2.264 ± 0.110  ops/s 
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine      uniqueKeys               false  thrpt   15   2.255 ± 0.190  ops/s

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI.

The existing implementation only sampled the key/accumulator size but always measured the size of the window. Note the 50-75% improvement for non-globally windowed accumulation.

There are also some trivial reductions hashCode/equality since we know that certain types are always non-null.

Before
Benchmark                                                 (distribution)  (globallyWindowed)   Mode  Cnt   Score   Error  Units
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine         uniform                true  thrpt   15  12.775 ± 0.640  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine         uniform               false  thrpt   15   6.047 ± 0.535  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          normal                true  thrpt   15   7.148 ± 0.473  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          normal               false  thrpt   15   4.233 ± 0.239  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          hotKey                true  thrpt   15  13.894 ± 0.649  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          hotKey               false  thrpt   15   6.708 ± 0.375  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine      uniqueKeys                true  thrpt   15   2.286 ± 0.115  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine      uniqueKeys               false  thrpt   15   1.765 ± 0.064  ops/s

After
Benchmark                                                 (distribution)  (globallyWindowed)   Mode  Cnt   Score   Error  Units
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine         uniform                true  thrpt   15  13.399 ± 0.241  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine         uniform               false  thrpt   15  11.522 ± 1.120  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          normal                true  thrpt   15   7.186 ± 0.123  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          normal               false  thrpt   15   6.578 ± 0.161  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          hotKey                true  thrpt   15  13.467 ± 0.562  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          hotKey               false  thrpt   15   9.704 ± 0.866  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine      uniqueKeys                true  thrpt   15   2.264 ± 0.110  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine      uniqueKeys               false  thrpt   15   2.255 ± 0.190  ops/s
@lukecwik lukecwik changed the title Update to grouping table to sample window size as well Update grouping table to sample window size as well Nov 29, 2022
@github-actions github-actions bot added the java label Nov 29, 2022
@github-actions
Copy link
Contributor

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @robertwb for label java.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@lukecwik
Copy link
Member Author

Run Java PreCommit

@lukecwik
Copy link
Member Author

R: @bhisevishal

@github-actions
Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

@@ -189,16 +184,10 @@ <K> WindowedGroupingTableKey(
K key,
Collection<? extends BoundedWindow> windows,
Coder<K> keyCoder,
SizeEstimator<K> keySizer) {
SizeEstimator sizer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be a SizeEstimator? Or is there a reason size estimators are all untyped now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Caches::weigh doesn't care about type. It relies on Jamm which uses java's instrumentation API to measure the size of the object in memory.

@lukecwik
Copy link
Member Author

Run Java PreCommit

@damccorm
Copy link
Contributor

Run Java Precommit

@lukecwik
Copy link
Member Author

lukecwik commented Dec 6, 2022

R: @damccorm

Copy link
Contributor

@damccorm damccorm left a comment

Choose a reason for hiding this comment

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

LGTM

@lukecwik lukecwik merged commit 27c355c into apache:master Dec 8, 2022
lostluck pushed a commit to lostluck/beam that referenced this pull request Dec 22, 2022
The existing implementation only sampled the key/accumulator size but always measured the size of the window. Note the 50-75% improvement for non-globally windowed accumulation.

There are also some trivial reductions hashCode/equality since we know that certain types are always non-null.

Before
Benchmark                                                 (distribution)  (globallyWindowed)   Mode  Cnt   Score   Error  Units
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine         uniform                true  thrpt   15  12.775 ± 0.640  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine         uniform               false  thrpt   15   6.047 ± 0.535  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          normal                true  thrpt   15   7.148 ± 0.473  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          normal               false  thrpt   15   4.233 ± 0.239  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          hotKey                true  thrpt   15  13.894 ± 0.649  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          hotKey               false  thrpt   15   6.708 ± 0.375  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine      uniqueKeys                true  thrpt   15   2.286 ± 0.115  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine      uniqueKeys               false  thrpt   15   1.765 ± 0.064  ops/s

After
Benchmark                                                 (distribution)  (globallyWindowed)   Mode  Cnt   Score   Error  Units
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine         uniform                true  thrpt   15  13.399 ± 0.241  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine         uniform               false  thrpt   15  11.522 ± 1.120  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          normal                true  thrpt   15   7.186 ± 0.123  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          normal               false  thrpt   15   6.578 ± 0.161  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          hotKey                true  thrpt   15  13.467 ± 0.562  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine          hotKey               false  thrpt   15   9.704 ± 0.866  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine      uniqueKeys                true  thrpt   15   2.264 ± 0.110  ops/s
PrecombineGroupingTableBenchmark.sumIntegerBinaryCombine      uniqueKeys               false  thrpt   15   2.255 ± 0.190  ops/s
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

3 participants