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

8308116: jdk.test.lib.compiler.InMemoryJavaCompiler.compile does not close files #14001

Closed
wants to merge 9 commits into from

Conversation

xmas92
Copy link
Member

@xmas92 xmas92 commented May 16, 2023

jdk.test.lib.compiler.InMemoryJavaCompiler.compile(String className, CharSequence sourceCode, String... options) creates a JavaFileManager but fails to close it after the CompilationTask is completed, leaving the file descriptors open until reference processing kicks in.

Graph below shows number of open file descriptors before and after this patch for a program which compiles dummy classes in a loop.
Before and after

Testing: GHA and Oracle CI tier1-3. Tests using jdk.test.lib.compiler.InMemoryJavaCompiler also tested locally.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8308116: jdk.test.lib.compiler.InMemoryJavaCompiler.compile does not close files

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14001/head:pull/14001
$ git checkout pull/14001

Update a local copy of the PR:
$ git checkout pull/14001
$ git pull https://git.openjdk.org/jdk.git pull/14001/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14001

View PR using the GUI difftool:
$ git pr show -t 14001

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14001.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 16, 2023

👋 Welcome back aboldtch! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label May 16, 2023
@openjdk
Copy link

openjdk bot commented May 16, 2023

@xmas92 The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label May 16, 2023
@mlbridge
Copy link

mlbridge bot commented May 16, 2023

Webrevs

Copy link
Member

@lmesnik lmesnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are few nits inline.
Also, please update copyright years.

return CloseableCompilationTask.createTask(null, new FileManagerWrapper(file, moduleOverride), null, opts, null, Arrays.asList(file));
}

private static class CloseableCompilationTask implements Closeable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make a sense to implement Callable as well? Just to make semantic clearer. (It is just suggestion.)

return new CloseableCompilationTask(task, fileManager);
}

public void close() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tag Override.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it be better to wrap IOException into RuntimeException here and don't have any 'throws' but it is up to you.

@openjdk
Copy link

openjdk bot commented May 16, 2023

@xmas92 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:

8308116: jdk.test.lib.compiler.InMemoryJavaCompiler.compile does not close files

Reviewed-by: lmesnik, stefank, jlahoda

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 119 new commits pushed to the master branch:

  • eb11508: 8308281: Java snippets in the FFM API need to be updated
  • 26227a6: 8305073: Fix VerifyLoopOptimizations - step 2 - verify idom
  • 80d7de7: 8305582: Compiler crash when compiling record patterns with var
  • e559613: 8308500: ZStatSubPhase::register_start should not call register_gc_phase_start if ZAbort::should_abort()
  • bdd2402: 8260943: C2 SuperWord: Remove dead vectorization optimization added by 8076284
  • 4f0f776: 8308403: [s390x] separate remaining_cargs from z_abi_160
  • 06b0a5e: 8302652: [SuperWord] Reduction should happen after loop, when possible
  • 69f508a: 8308300: enhance exceptions in MappedMemoryUtils.c
  • c440827: 8308093: Disable language preview features use in JDK
  • 422128b: 8306992: [JVMCI] mitigate more against JVMCI related OOME causing VM to exit
  • ... and 109 more: https://git.openjdk.org/jdk/compare/01892f9c6ed1ff6593f77b89fcc2c5da8d094abf...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 16, 2023
xmas92 and others added 4 commits May 19, 2023 13:30
@xmas92
Copy link
Member Author

xmas92 commented May 22, 2023

Got the suggestion to close the fileManager directly. It require some extra refactoring. But does not change the class hierarchy so no test need to be changed. Creating a cleaner patch.

There are some parts that could be extracted into helper methods, but the compile method seems small enough to not require this. And it is harder to keep such a refactoring clean without introducing changes to the class hierarchy.

Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable.

@xmas92
Copy link
Member Author

xmas92 commented May 23, 2023

Thanks for the reviews
/integrate

@openjdk
Copy link

openjdk bot commented May 23, 2023

Going to push as commit e9320f3.
Since your change was applied there have been 125 commits pushed to the master branch:

  • 97d3b27: 8307523: [vectorapi] Optimize MaskFromLongBenchmark.java
  • bb0ff48: 8305091: Change ChaCha20 cipher init behavior to match AES-GCM
  • c0c4d77: 8308544: Fix compilation regression from JDK-8306983 on musl libc
  • 9e196b3: 8308565: HttpClient: Sanitize logging while stopping
  • 582ddeb: 8308545: java/net/httpclient/ShutdownNow.java fails with "stream 1 cancelled"
  • 1cfb265: 8307814: In the case of two methods with Record Patterns, the second one contains a line number from the first method
  • eb11508: 8308281: Java snippets in the FFM API need to be updated
  • 26227a6: 8305073: Fix VerifyLoopOptimizations - step 2 - verify idom
  • 80d7de7: 8305582: Compiler crash when compiling record patterns with var
  • e559613: 8308500: ZStatSubPhase::register_start should not call register_gc_phase_start if ZAbort::should_abort()
  • ... and 115 more: https://git.openjdk.org/jdk/compare/01892f9c6ed1ff6593f77b89fcc2c5da8d094abf...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 23, 2023
@openjdk openjdk bot closed this May 23, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 23, 2023
@openjdk
Copy link

openjdk bot commented May 23, 2023

@xmas92 Pushed as commit e9320f3.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

5 participants