On Wed, 16 Nov 2022 19:04:29 GMT, Andrew Haley wrote:
>> Probably so, yes. I'll have a look at that along with caching failure.
>
> So I just did the experiment of caching failures and the result of
> `isBound()`.
>
> This test:
>
>
> @Benchmark
> @OutputTimeUnit(TimeUnit.NANOSECONDS)
> public int thousandMaybeGets(Blackhole bh) throws Exception {
> int result = 0;
> for (int i = 0; i < 1_000; i++) {
> if (ScopedValuesData.sl1.isBound()) {
> result += ScopedValuesData.sl1.get();
> }
> }
> return result;
> }
>
>
>
> Before and after:
>
>
> ScopedValues.thousandMaybeGets avgt 10 13436.112 ± 20.885 ns/op
> ScopedValues.thousandMaybeGets avgt 10 56.315 ± 0.583 ns/op
>
>
> You may have a point. The experiment is on a branch called
> `JDK-828-cache-queries` in [My personal
> repo](https://github.com/theRealAph/jdk).
>
> I'd push it now but it's getting a bit late to make such changes now. WDYT?
Fixed.
-
PR: https://git.openjdk.org/jdk/pull/10952