Commit 84fff31
perf(java): replace synchronized single instance with WASM instance pool (#104)
## Summary
- Replaces the single `synchronized` WASM instance with a pool of
instances (`ArrayBlockingQueue`), sized to `availableProcessors()` by
default
- Pre-evaluated (static/disabled) flags served lock-free via volatile
`CacheSnapshot`
- Targeting flags acquire a pooled instance, evaluate, and return it —
enabling parallel evaluation
- `updateState()` drains the pool, updates instances (in parallel for
N>1), stamps a generation counter, and atomically swaps the cache
- Generation guard ensures cache consistency between volatile read and
pool acquire
## Benchmark Results (16 threads, LayeredEvaluationContext)
| Scenario | µs/op | ops/µs | B/op | vs Old |
|----------|-------|--------|------|--------|
| Pre-evaluated | 0.014 | 1,083 | ~0 | **8.5x faster** |
| Targeting (large ctx) | 56.3 | 0.292 | 3,905 | **1.9x faster** |
WASM allocations are **constant at ~3.9 KB** regardless of context size
(old resolver scales linearly: 9K → 18K → 37K).
## Test plan
- [x] Concurrent evaluation: 8 threads × 100 iterations with targeting
flags
- [x] Concurrent update + evaluate: 1 writer + 4 readers simultaneously
- [x] Pool size 1 regression test
- [x] Pool size constructor validation
Refs: #101
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent a4ea118 commit 84fff31
0 file changed
0 commit comments