On Tue, 14 Apr 2026 11:21:27 GMT, Paul Hübner <[email protected]> wrote:
> Hi all,
>
> The Java FF&M API includes functionality to both initialize and read from
> thread-local data prior to and immediately after downcalls, respectively,
> through the `Linker.Option::captureCallState` API. This is useful, as an
> example, when setting or capturing `errno` when interfacing with C functions.
> However, using this linker option introduces some invocation overhead at
> runtime.
>
> This RFE introduces a JMH microbenchmark which quantifies this overhead. A
> simple downcall to `strtoll` is measured with and without call state
> capturing.
>
> Testing: GHA for sanity testing.
>
> # Benchmarking Results
>
> I have executed this benchmark on Oracle-supported platforms, the results can
> be found below. For each platform, I've done two trials corresponding to
> different JDKs: one being the current HEAD ("current", based on
> 28506ca7a8f03cddb0903e4f58b4f38742f15606), and one with
> [JDK-8378559](https://bugs.openjdk.org/browse/JDK-8378559) reverted
> ("legacy", revert commit on top of 28506ca7a8f03cddb0903e4f58b4f38742f15606).
> This one-off experiment is insightful since
> [JDK-8378559](https://bugs.openjdk.org/browse/JDK-8378559) increased the
> overhead of downcalls using state capturing by introducing thread-local data
> initialization. The performance impact of this change was previously
> unquantified.
>
> ## Linux x64
>
> **Current:**
>
> Benchmark Mode Cnt Score
> Error Units
> CaptureCallStateOverheadBench.doNotUseCaptureCallState avgt 30 39.261 ±
> 0.025 ns/op
> CaptureCallStateOverheadBench.useCaptureCallState avgt 30 45.539 ±
> 0.653 ns/op
>
>
> **Legacy:**
>
> Benchmark Mode Cnt Score
> Error Units
> CaptureCallStateOverheadBench.doNotUseCaptureCallState avgt 30 39.249 ±
> 0.015 ns/op
> CaptureCallStateOverheadBench.useCaptureCallState avgt 30 43.887 ±
> 1.919 ns/op
>
>
> ## Linux AArch64
>
> **Current:**
>
> Benchmark Mode Cnt Score
> Error Units
> CaptureCallStateOverheadBench.doNotUseCaptureCallState avgt 30 47.175 ±
> 0.067 ns/op
> CaptureCallStateOverheadBench.useCaptureCallState avgt 30 58.490 ±
> 0.532 ns/op
>
>
> **Legacy:**
>
> Benchmark Mode Cnt Score
> Error Units
> CaptureCallStateOverheadBench.doNotUseCaptureCallState avgt 30 47.396 ±
> 0.217 ns/op
> CaptureCallStateOverheadBench.useCaptureCallState avgt 30 53.341 ±
> 0.101 ns/op
>
>
> ## macOS x64
>
> **Current:**
>
> Benchmark...
This pull request has now been integrated.
Changeset: 8de6298e
Author: Paul Hübner <[email protected]>
URL:
https://git.openjdk.org/jdk/commit/8de6298ed59b4764e6f8897e99f03c7723930cde
Stats: 115 lines in 1 file changed: 115 ins; 0 del; 0 mod
8379630: Add JMH benchmark to measure the overhead of using captured call state
Reviewed-by: pminborg, jvernee, liach
-------------
PR: https://git.openjdk.org/jdk/pull/30719