He-Pin opened a new pull request, #3312: URL: https://github.com/apache/pekko/pull/3312
### Motivation `HashCode.hash` iterates JVM arrays through `java.lang.reflect.Array`, adding reflective per-element access and boxing in a shared utility. A focused JDK 17 JMH comparison showed this path is substantially slower than typed array loops. ### Modification - Dispatch all nine JVM array kinds to typed `while` loops. - Add a directional test that uses the original `java.lang.reflect.Array` algorithm as the parity oracle for primitive, reference, empty, null-element, and nested arrays. - Add a reproducible JMH benchmark for primitive and reference arrays. ### Result Hash values remain compatible while the measured array paths improve by roughly 39x to 135x. JDK 17, 2 forks, 5 warmup iterations, 8 measurement iterations, 250 ms each: | Benchmark | `main` | optimized | speedup | |---|---:|---:|---:| | `Int[16]` | 824.277 ns/op | 6.106 ns/op | 135.0x | | `Int[256]` | 12749.433 ns/op | 183.033 ns/op | 69.7x | | `AnyRef[16]` | 635.492 ns/op | 13.945 ns/op | 45.6x | | `AnyRef[256]` | 9491.604 ns/op | 240.387 ns/op | 39.5x | ### Tests - `sbt "actor-tests / Test / testOnly org.apache.pekko.util.HashCodeSpec"` - passed, 3 tests - `sbt "++3.3.8" "actor-tests / Test / testOnly org.apache.pekko.util.HashCodeSpec"` - passed, 3 tests - `sbt "bench-jmh/Jmh/run -wi 5 -i 8 -f 2 -w 250ms -r 250ms -t 1 -p size=16,256 .*HashCodeArrayBenchmark.*"` - passed; results above - `sbt +headerCheckAll` - passed - `sbt checkCodeStyle` - passed - `scalafmt --list --mode diff-ref=origin/main` - passed - `git diff --check` - passed - `qodercli` formal stdout review - no must-fix findings ### References Refs #3300 -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
