mdproctor opened a new issue, #6668:
URL: https://github.com/apache/incubator-kie-drools/issues/6668

   ## Summary
   
   Track all work to exploit Java platform features (Java 25 LTS through Java 
27) for drools-beliefs Bayesian inference performance. This complements the 
incremental inference implementation (Phases 1–3) which delivered ~20–25% 
algorithmic improvement on Java 17.
   
   ## Benchmarks: Java 17 vs Java 25 (SimpleBenchmark, 20k warmup / 100k 
measurement, chain topology)
   
   | Benchmark | Java 17 n=128 | Java 25 n=128 | Δ |
   |---|---|---|---|
   | baselineFull | 74.69 µs | 68.21 µs | **-8.7%** |
   | singleEvidenceChange | 54.79 µs | 55.72 µs | ~same |
   | fastRetraction | 54.17 µs | 52.90 µs | -2.4% |
   
   Note: comparison uses same bytecode, different JVM. G1 default GC both runs. 
Java 25's JIT gives ~8% gain on full-reset baseline. Incremental paths show 
smaller JIT benefit because they do less work per call.
   
   ## Child Issues
   
   - [ ] **Vector API (SIMD) on PotentialMultiplier / BayesProjection / 
BayesAbsorption** — JEP 529 (incubating, Java 26). Vectorise the inner 
`double[]` multiply/divide loops. Requires `--add-modules 
jdk.incubator.vector`. API is stable in practice despite incubating status. 
Expected: 2–4× on the arithmetic-heavy paths.
   - [ ] **Compact Object Headers** — JEP 519 (finalized Java 25, opt-in via 
`-XX:+UseCompactObjectHeaders`). Object headers shrink 96→64 bits. Reduces heap 
pressure and improves cache line utilisation when iterating `CliqueState[]` / 
`SeparatorState[]` arrays.
   - [ ] **AOT Method Profiling** — JEP 515 (finalized Java 25). Cache JIT 
profiling data across JVM restarts. Eliminates warmup cost for long-running 
rule sessions. Particularly valuable when the junction tree is rebuilt on each 
`KieBase` load.
   - [ ] **Eliminate per-call `Arrays.copyOf` in `injectSnapshotAndAbsorb`** — 
Currently allocates a `double[]` on every clean-separator message (O(n) per 
incremental update). Pre-allocate per-separator `oldSepPots` arrays at 
construction time, same as `sepPotSnapshots`.
   - [ ] **Parallel distribute phase using Virtual Threads** — JEP 444 
(finalized Java 21). Independent subtrees in the distribute phase have no data 
dependency. Fan out to virtual threads; low overhead vs platform threads. Only 
beneficial for large networks (n > ~50) where distribute dominates.
   - [ ] **G1 GC dual card table** — JEP 522 (finalized Java 26). 5–15% 
throughput, 50% reduction in G1 background CPU. Zero code changes, flag 
`-XX:+UseG1GC` (already default). Verify with Java 26 runtime.
   - [ ] **ZGC + AOT cache** — JEP 516 (finalized Java 26). Previously ZGC and 
AOT were incompatible. Java 26 allows sub-millisecond GC pauses AND AOT warmup 
simultaneously. Worth benchmarking for latency-sensitive rule sessions.
   - [ ] **Value Classes (Valhalla)** — JEP 401 (first preview targeted Java 
27, Sept 2026). `CliqueState`, `SeparatorState`, `BayesVariableState` as value 
classes: flat heap layout, scalarized in JIT, eliminates header per-object. The 
largest potential gain but furthest away.
   - [ ] **Proper JMH benchmark suite** — Current `SimpleBenchmark` uses fixed 
iteration count insufficient for small networks. Upgrade to JMH 1.37 with 
proper `@Fork` and `--add-modules` support for Vector API benchmarks.
   
   ## Timeline
   
   | Feature | Java version | Status | Code change? |
   |---|---|---|---|
   | Compact Object Headers | 25 | Finalized (opt-in flag) | No |
   | AOT Method Profiling | 25 | Finalized | No |
   | G1 GC dual card table | 26 | Finalized | No |
   | ZGC + AOT cache | 26 | Finalized | No |
   | Virtual Threads (parallel distribute) | 21+ | Finalized | Yes — medium |
   | Vector API SIMD | 26 incubating | Incubating | Yes — significant |
   | Value Classes (Valhalla) | 27 preview (est.) | Pre-preview | Yes — 
significant |
   
   ## Notes
   
   - **Valhalla is NOT in Java 25 or 26.** JEP 401 is pre-preview EA on a JDK 
27 base. Earliest production use: Java 28 or 29.
   - **Vector API is NOT finalized in Java 26.** JEP 529 is the 11th incubator 
round with no API changes. It is blocked on Valhalla. Usable now under module 
flag; expect finalization in Java 27–28.
   - Machine has Java 17, 25, 26 installed. Project targets Java 25 (upgraded 
from 17 in this epic's prep work).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to