Uh oh!
There was an error while loading. Please reload this page.
HBASE-29253: Avoid allocating a new closure on every row processed by StoreScanner - #6901
Conversation
Apache-HBase
commented
Apr 11, 2025
🎊 +1 overall
This message was automatically generated. |
Apache-HBase
commented
Apr 11, 2025
🎊 +1 overall
This message was automatically generated. |
Apache9
commented
Apr 12, 2025
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: |
Apache9
commented
Apr 12, 2025
Better put the |
charlesconnell
commented
Apr 12, 2025
Sure. The full code is now and the results are similar: |
Apache9
commented
Apr 13, 2025
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.
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...
charlesconnell
commented
Apr 13, 2025
Yeah. To be sure, I just tried your suggestion like so: and the results stay the same. |
…StoreScanner (apache#6901) Signed-off-by: Duo Zhang <zhangduo@apache.org> (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.