Skip to content

Resolve ByteArrayMemory volatile access support once - #226

Open
andreas-karlsson wants to merge 1 commit into
bytecodealliance:mainfrom
andreas-karlsson:fix-bytearraymemory-jdk25
Open

andreas-karlsson wants to merge 1 commit into
bytecodealliance:mainfrom
andreas-karlsson:fix-bytearraymemory-jdk25

Conversation

@andreas-karlsson

Copy link
Copy Markdown
Contributor

This fixes the first part of #224, i.e. the catastrophic regression of ByteArrayMemory under JDK 25. It achieves this by calling isAccessModeSupported only once and reusing its result. On JDK 21 the call is cheap, but on JDK 25 where it returns false it's expensive.

Note: With this fix on JDK 25, ByteArrayMemory will fall back to the same lock path as ByteBufferMemory. Meaning roughly a 3x slowdown compared to JDK 21, so it still remains to provide a performant Memory impl. for JDK 25.

BenchmarkSievePrimes (4 threads, ops/s, higher is better; short runs: 1 fork, 3 iterations):

JDK 21 before JDK 21 after JDK 25 before JDK 25 after
compiled, ByteArrayMemory 71.8 ± 4.3 82.6 ± 18.0 0.32 ± 0.02 27.3 ± 10.0
compiled, ByteBufferMemory 23.2 ± 8.2 21.4 ± 1.2 23.7 ± 15.0 22.4 ± 11.7
interpreter, ByteArrayMemory 1.27 ± 0.50 1.25 ± 0.40 0.25 ± 0.10 0.78 ± 0.15
interpreter, ByteBufferMemory 0.97 ± 0.20 0.97 ± 0.49 0.86 ± 0.38 0.79 ± 0.38

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant