From 974abb065f576d8cabb34b0aed8c3cfd943ec65d Mon Sep 17 00:00:00 2001 From: Emanuel Peter Date: Fri, 16 Jan 2026 09:16:06 +0100 Subject: [PATCH] fix small issue in benchmark and add comment --- .../bench/vm/compiler/VectorAlgorithms.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorAlgorithms.java b/test/micro/org/openjdk/bench/vm/compiler/VectorAlgorithms.java index af0a5781719..26a02622897 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/VectorAlgorithms.java +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorAlgorithms.java @@ -233,15 +233,18 @@ public class VectorAlgorithms { @Benchmark public int findI_loop() { + // Every invocation should have a different value for e, so that + // we don't get branch-prediction that is too good. And also so + // that the position where we exit is more evenly distributed. idx = (idx + 1) & 0xffff; - int e = aI[idx]; + int e = eI[idx]; return VectorAlgorithmsImpl.findI_loop(aI, e); } @Benchmark public int findI_VectorAPI() { idx = (idx + 1) & 0xffff; - int e = aI[idx]; + int e = eI[idx]; return VectorAlgorithmsImpl.findI_VectorAPI(aI, e); } @@ -257,15 +260,18 @@ public class VectorAlgorithms { @Benchmark public Object filterI_loop() { + // Every invocation should have a different value for e, so that + // we don't get branch-prediction that is too good. And also so + // That the length of the resulting data is more evenly distributed. idx = (idx + 1) & 0xffff; - int e = aI[idx]; + int e = eI[idx]; return VectorAlgorithmsImpl.filterI_loop(aI, rI, e); } @Benchmark public Object filterI_VectorAPI() { idx = (idx + 1) & 0xffff; - int e = aI[idx]; + int e = eI[idx]; return VectorAlgorithmsImpl.filterI_VectorAPI(aI, rI, e); }