-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8347408: Create an internal method handle adapter for system calls with errno #23765
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
Conversation
|
👋 Welcome back pminborg! A progress list of the required criteria for merging this PR into |
|
/reviewers 2 reviewer |
|
❗ This change is not yet ready to be integrated. |
src/java.base/share/classes/jdk/internal/foreign/CaptureStateUtil.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/jdk/internal/foreign/CaptureStateUtil.java
Outdated
Show resolved
Hide resolved
| // Do not use a lambda in order to allow early use in the init sequence | ||
| // This is equivalent to: | ||
| // computeIfAbsent(basicKey, CaptureStateUtil::basicHandleFor); | ||
| .computeIfAbsent(basicKey, new Function<>() { |
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 recommend a local record and capture the record instance in a member static final field. This code creates a function on every call. Also might be of interest whether we should use get + putIfAbsent or computeIfAbsent, as CHM has some bug that makes cIA slower than get for certain access patterns.
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.
Performance is not critical to this method so I would prioritize maintainability over performance here.
src/java.base/share/classes/jdk/internal/foreign/CarrierLocalArenaPools.java
Outdated
Show resolved
Hide resolved
Webrevs
|
|
@minborg This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
@minborg This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
|
/open |
|
@minborg This pull request is now open |
|
The code looks good to me; please wait for people more professional with FFM internals like @JornVernee or @mcimadamore. |
| return this instanceof NoInitSegmentAllocator noInit ? | ||
| noInit.allocateNoInit(byteSize, 1) : | ||
| allocate(byteSize); |
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.
| return this instanceof NoInitSegmentAllocator noInit ? | |
| noInit.allocateNoInit(byteSize, 1) : | |
| allocate(byteSize); | |
| return this instanceof NoInitSegmentAllocator noInit | |
| ? noInit.allocateNoInit(byteSize, 1) | |
| : allocate(byteSize); |
How about a different coding style?
|
I will close this PR and create a new one against the bug report using the newly integrated |
As we advance, converting older JDK code to use the relatively new FFM API requires system calls that can provide
errnoand the likes to explicitly allocate aMemorySegmentto capture potential error states. This can lead to negative performance implications if not designed carefully and also introduces unnecessary code complexity.Hence, this PR proposes adding a JDK internal method handle adapter that can be used to handle system calls with
errno,GetLastError, andWSAGetLastError.It relies on an efficient carrier-thread-local cache of memory regions to allide allocations.
Here are some benchmarks that ran on a platform thread and virtual threads respectively (M1 Mac):
Adapted system call:
Explicit allocation:
Thread Local allocation:
The adapted system call exhibits a ~4x performance improvement over the existing "explicit allocation" scheme for the happy path on platform threads. Because there needs to be sharing across threads for virtual-thread-capable carrier threads, these are a bit slower ("only" ~3x faster).
Here are some benchmarks for the underlying ArenaPool (M1 Mac):
Note: The pool size for the above benchmarks was 32 bytes.
This PR relates to #23391 we had to back out. This PR attempts to ensure, that the problems encountered there do not surface in this PR.
The arena pool is able to share recyclable memory across several arenas, for platform threads.
This PR passes tier1, tier2, and tier3 testing.
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23765/head:pull/23765$ git checkout pull/23765Update a local copy of the PR:
$ git checkout pull/23765$ git pull https://git.openjdk.org/jdk.git pull/23765/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 23765View PR using the GUI difftool:
$ git pr show -t 23765Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23765.diff
Using Webrev
Link to Webrev Comment