RFR: 8347408: Create an internal method handle adapter for system calls with errno [v7]

Per Minborg pminborg at openjdk.org
Thu May 8 07:54:17 UTC 2025


On Thu, 8 May 2025 07:40:44 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> As we advance, converting older JDK code to use the relatively new FFM API requires system calls that can provide `errno` and the likes to explicitly allocate a MemorySegment to 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`, and `WSAGetLastError`.
>> 
>> It relies on an efficient carrier-thread-local cache of memory regions to allide allocations.
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Clean up and remove unrelated changed

Updated benchmarks:


Benchmark                                                  Mode  Cnt   Score   Error  Units
CaptureStateUtilBench.OfVirtual.adaptedSysCallFail         avgt   30  34.138 ± 0.269  ns/op
CaptureStateUtilBench.OfVirtual.adaptedSysCallSuccess      avgt   30  12.660 ± 0.251  ns/op
CaptureStateUtilBench.OfVirtual.explicitAllocationFail     avgt   30  39.592 ± 0.319  ns/op
CaptureStateUtilBench.OfVirtual.explicitAllocationSuccess  avgt   30  21.379 ± 0.162  ns/op
CaptureStateUtilBench.adaptedSysCallFail                   avgt   30  30.636 ± 0.410  ns/op
CaptureStateUtilBench.adaptedSysCallSuccess                avgt   30   4.990 ± 0.042  ns/op
CaptureStateUtilBench.explicitAllocationFail               avgt   30  39.763 ± 0.316  ns/op
CaptureStateUtilBench.explicitAllocationSuccess            avgt   30  21.420 ± 0.241  ns/op

-------------

PR Comment: https://git.openjdk.org/jdk/pull/25043#issuecomment-2862103792


More information about the core-libs-dev mailing list