Batch Read Loop Unrolling Optimization for Dictionary Reads#135
Open
siddharthteotia wants to merge 2 commits into
Open
Batch Read Loop Unrolling Optimization for Dictionary Reads#135siddharthteotia wants to merge 2 commits into
siddharthteotia wants to merge 2 commits into
Conversation
Consolidate performance results into a single comprehensive table showing all batch sizes, access patterns, and dictionary types for easier comparison. Add detailed technical explanation of JIT compiler behavior and why manual loop unrolling benefits small batches but shows no improvement at large batch sizes where JIT optimization dominates. Format all tables with proper alignment.
Collaborator
Author
|
Some weird licensing issue is failing tests. Will look locally via claude and fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and Solution Overview
JIRA: OA-837
Optimized dictionary batch read operations through 8x loop unrolling for all numeric types (int, long, float, double).
Before (Scalar Loop) - One value per iteration, high branch overhead, CPU pipeline underutilized.
After (8x Loop Unrolling)
Benefits
Solution Details
All below methods in the base Dictionary implementation are optimized
Primitive types:
readIntValues(int[] dictIds, int length, int[] outValues)readLongValues(int[] dictIds, int length, long[] outValues)readFloatValues(int[] dictIds, int length, float[] outValues)readDoubleValues(int[] dictIds, int length, double[] outValues)Boxed types:
readIntValues(int[] dictIds, int length, Integer[] outValues)readLongValues(int[] dictIds, int length, Long[] outValues)readFloatValues(int[] dictIds, int length, Float[] outValues)readDoubleValues(int[] dictIds, int length, Double[] outValues)All implementations using default methods automatically benefit:
IntDictionary,LongDictionary,FloatDictionary,DoubleDictionaryOnHeapIntDictionary,OnHeapLongDictionary,OnHeapFloatDictionary,OnHeapDoubleDictionaryTesting Done
New Unit Tests in DictionaryBatchReadTest.java
-- 18 test cases covering boundary conditions (empty, <8, =8, =16, >8 elements, random access)
New Performance Tests in JMBenchmarkDictionaryBatchRead.java
Backward compatible (no API changes)
Performance Results
Why On-Heap Benefits More:
int[] _dictIdToVal)Why Off-Heap Shows Less Improvement:
Future Optimizations
On-Heap Dictionary Specialization
System.arraycopy()Software Prefetching
SIMD Kernel
References