-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8333086: Using Console.println is unnecessarily slow due to JLine initalization #19479
Conversation
… really necessary.
👋 Welcome back jlahoda! A progress list of the required criteria for merging this PR into |
@lahodaj This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 173 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
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.
It looks like a legit performance trick.
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.
Looks good with a minor nit.
for (TestCase tc : testCases) { | ||
ProcessBuilder builder = | ||
ProcessTools.createTestJavaProcessBuilder("--enable-preview", | ||
"-verbose:class", |
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.
Better to explicitly specify -Djdk.console=jdk.internal.le
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.
LGTM. Thanks for the changes.
/integrate |
Going to push as commit f7dbb98.
Your commit was automatically rebased without conflicts. |
Consider these two programs:
and:
They do the same conceptual thing - write a text to the output. But,
IO.println
delegates toConsole.println
, which then delegates to aConsole
backend, and the default backend is currently based on JLine.The issues is that JLine takes a quite a long time to initialize, and in a program like this, JLine is not really needed - it is used to provide better editing experience when reading input, but there's no reading in these programs.
For example, on my computer:
The proposal herein is to delegate to the simpler
Console
backend fromjava.base
as long as the user only uses methods that print to output, and switch to the JLine delegate when other methods (typically input) is used. Note that while technicallywriter()
is a method doing output, it will force JLine initialization to avoid possible problems if the client caches the writer and uses it after switching the delegates.With this patch, I can get timing like this:
which seems much more acceptable.
There is also #19467, which may reduce the time further.
A future work might focus on making JLine initialize faster, but avoiding JLine initialization in case where we don't need it seems like a good step to me in any case.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19479/head:pull/19479
$ git checkout pull/19479
Update a local copy of the PR:
$ git checkout pull/19479
$ git pull https://git.openjdk.org/jdk.git pull/19479/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 19479
View PR using the GUI difftool:
$ git pr show -t 19479
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19479.diff
Webrev
Link to Webrev Comment