You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: replace anonymous Member classes with concrete ExprFieldMember/MethodFieldMember (#756)
## Summary
- Replace the two anonymous `Val.Obj.Member` subclasses in
`visitMemberList` with concrete `ExprFieldMember` and
`MethodFieldMember` classes, giving the JIT a monomorphic type at every
`invoke()` call site for better inlining.
- Extract the shared scope-caching logic
(`makeNewScope`/`createNewScope` closures) into an `ObjectScopeFactory`
class. All fields from the same object literal share one factory,
preserving per-object scope caching while eliminating per-field closure
allocations.
## Benchmark results
JMH regression suite (`bench.runRegressions`), JDK 21.0.10, single fork,
1 warmup + 1 measurement iteration (10s):
| Benchmark | Before | After | Change |
|-----------|--------|-------|--------|
| bench.07 (object fibonacci) | 9.948 ms | 5.049 ms | **-49.2%** |
| comparison | 6.941 ms | 4.201 ms | **-39.5%** |
| large_string_template | 5.591 ms | 3.830 ms | **-31.5%** |
| base64 | 1.150 ms | 0.812 ms | **-29.4%** |
| large_string_join | 1.476 ms | 1.053 ms | **-28.7%** |
| base64_byte_array | 2.925 ms | 2.160 ms | **-26.2%** |
| bench.04 | 0.486 ms | 0.372 ms | **-23.5%** |
| realistic1 | 4.592 ms | 3.550 ms | **-22.7%** |
| base64DecodeBytes | 17.514 ms | 13.667 ms | **-22.0%** |
| foldl | 0.277 ms | 0.219 ms | **-20.9%** |
| gen_big_object | 2.345 ms | 1.947 ms | **-17.0%** |
| realistic2 | 115.444 ms | 97.620 ms | **-15.4%** |
| assertions | 0.532 ms | 0.464 ms | **-12.8%** |
| bench.09 | 0.079 ms | 0.070 ms | **-11.4%** |
No regressions observed (remaining benchmarks within noise).
## Test plan
- [x] `./mill 'sjsonnet.jvm[3.3.7]'.test` — all tests pass
- [x] `./mill __.checkFormat` — formatting verified
- [x] JMH regression benchmarks compared to baseline
0 commit comments