-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8359119: Change Charset to use StableValue #25727
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
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back pminborg! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
Webrevs
|
Current startup performance on an M1 macOS using Base:
Patch:
|
static final ThreadTracker TRACKER = new ThreadTracker(); | ||
} | ||
private static final Supplier<ThreadTracker> TRACKER = StableValue.supplier( | ||
new Supplier<>() { public ThreadTracker get() { return new ThreadTracker(); }}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ThreadTracker pre-dates ScopedValue. We could potentially use a ScopedValue<Boolean> IN_LOOKUP
here, or StableValue<ScopedValue<Boolean>>
if there are issues running the class initializer in early VM startup. Separate discussion but we don't need ThreadTracker now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, revert the changes here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's okay, it's just that the change is a reminder that all ThreadTracker usages can be replaced with a ScopedValue but may require a bit of work to allow using during early VM startup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chatted with Andrew Haley yesterday about allowing ScopedValue be used in early startup. Charset is initialized very early in initPhase1, when initializing the system properties, so easy to get recursive initialization issues that surface or NPE or other exceptions. There are several ways we can fix this and it means that TRACKER is not needed. I don't mind if we change it to use a StableValue now but I expect we will change it very soon to remove ThreadTracker and just replace with ScopedValue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue with using ScopedValue early in startup is resolved so we can use private static final ScopedValue<Boolean> IN_LOOKUP = ScopedValue.newInstance();
and get rid of the use of ThreadTracker from this class.
int n = 0; | ||
ServiceLoader<CharsetProvider> sl = | ||
private static final Supplier<List<CharsetProvider>> EXTENDED_PROVIDERS = StableValue.supplier( | ||
new Supplier<>() { public List<CharsetProvider> get() { return extendedProviders0(); }}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one looks okay.
private static Charset defaultCharset0() { | ||
return Objects.requireNonNullElse( | ||
standardProvider.charsetForName(StaticProperty.fileEncoding()), | ||
sun.nio.cs.UTF_8.INSTANCE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would more readable to keep the if-then-else rather than using requireNonNullElse here.
private final String name; // tickles a bug in oldjavac | ||
@Stable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we touching these then we can remove the "tickles a bug in oldjavac" comment as I think that goes back to before JDK 5.
Overall I think this is okay but will need to run startup benchmarks due to this class being used in early startup. |
After this proposal, the startup will load 9 more classes
public class Startup {
public static void main(String[] args) throws Exception {
Thread.sleep(1000);
}
} ./build/macosx-aarch64-server-release/images/jdk/bin/java -verbose:class Startup By comparing the output before and after this proposal, we can see that 9 more classes are loaded, as follows:
|
Fields and methods can better leverage the Stable Value API compared to using DCL and holder classes. There are also some fields that can be marked
@Stable
.This PR passes tier1, tier2, and tier3 tests on multiple platforms.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25727/head:pull/25727
$ git checkout pull/25727
Update a local copy of the PR:
$ git checkout pull/25727
$ git pull https://git.openjdk.org/jdk.git pull/25727/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25727
View PR using the GUI difftool:
$ git pr show -t 25727
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25727.diff
Using Webrev
Link to Webrev Comment