xuliang0317 opened a new pull request, #8287: URL: https://github.com/apache/hbase/pull/8287
Optimize Bloom Filter bit operations by replacing array lookup with bitwise shift While this is functional, it introduces unnecessary overhead in the read path, which is highly performance-sensitive: Array Bounds Checking: The JVM must perform bounds checking for every array access to prevent ArrayIndexOutOfBoundsException, which adds minor but cumulative overhead. Memory Access: Even though bitvals is likely cached in L1/L2 CPU cache, it still requires a memory load instruction. Division/Modulo Overhead: In BloomFilterChunk#set(long pos), the code uses / 8 and % 8 which compiles to relatively expensive division instructions. Solution This PR optimizes the Bloom Filter bit operations by replacing the array lookup with direct bitwise shifts and optimizing the division/modulo operations: Direct Bitwise Shift: Replaced BloomFilterUtil.bitvals[bitPos] with (1 << bitPos). This eliminates array bounds checks completely. The JIT compiler can optimize 1 << bitPos into a single, extremely fast CPU instruction (SHL), executing entirely within CPU registers with zero memory access latency. Remove Unused Array: Removed the BloomFilterUtil.bitvals array completely to clean up the code. Division to Shift Optimization: In BloomFilterChunk#set(long pos), replaced pos / 8 and pos % 8 with pos >> 3 and pos & 7. Since pos is always non-negative in this context, this is a safe and much faster alternative to division instructions. Proposed Changes(去掉了不必要的数字,改成了位运算) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
