-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29253: Avoid allocating a new closure on every row processed by StoreScanner #6901
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
HBASE-29253: Avoid allocating a new closure on every row processed by StoreScanner #6901
Conversation
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
The java compiler will not do it automatically? Do you have microbenmark to show the improvement? Thanks. |
|
Sure, here's a microbenchmark: which produced these results for me: The test runs somewhat faster when it doesn't create a new lambda on each loop iteration (33571 op/sec versus 37243 op/sec). The allocation rate is vastly lower (4876 MB/sec versus 0.5 MB/sec). My Java version: |
|
Better put the |
|
Sure. The full code is now and the results are similar: |
|
Please use this form Not If compile can not pass, use casting instead of storing it to a local variable. |
Apache9
left a comment
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.
OK, asked chatgpt, if a lambda captures external variables, even if these vars are not changed during the whole loop, it will still create a instance every time...
|
Yeah. To be sure, I just tried your suggestion like so: and the results stay the same. |
…StoreScanner (#6901) Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit abc8b43)
…StoreScanner (#6901) Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit abc8b43)
…StoreScanner (#6901) Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit abc8b43)
…StoreScanner (apache#6901) Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit abc8b43)
I've looked at a lot of allocation profiles of RegionServers doing a read-heavy workload. Some allocations that dominate the chart can be easily avoided. The method
StoreScanner#read()contains this codethat runs for every iteration of its main loop. A closure can be created before the loop and re-used instead.