Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AccessMode.CONCURRENT should use a static final VarHandle to access its array #5216

Closed
franz1981 opened this issue May 30, 2024 · 0 comments
Closed
Labels
Milestone

Comments

@franz1981
Copy link
Contributor

private final VarHandle LOCALS_UPDATER = MethodHandles.arrayElementVarHandle(Object[].class);
in theory is used on the CONCURRENT instance which is stored in a static final-like (in term of semantic) field within AccessMode, but still IDK if the JIT trust transitively the final fields within the CONCURRENT class, so, this can cause a severe performance penalty while using its VarHandle.

It means it would be better to have a JMH benchmark to prove that everything it's fine there OR at just move VarHandle LOCALS_UPDATER into some proper static final declaration. See https://shipilev.net/jvm/anatomy-quarks/17-trust-nonstatic-final-fields/#_observations which is indeed related VarHandle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants