Commit c0bc815
committed
perf: abstract FormatCache as pluggable trait, optimize format runtime
Extract format string cache from static field in Format.scala into a
pluggable FormatCache trait (analogous to ParseCache). This allows users
to supply custom cache implementations (e.g., Caffeine-based) via the
Interpreter/Evaluator constructors.
Key changes:
- New FormatCache trait with getOrElseUpdate API
- DefaultFormatCache: LRU LinkedHashMap (256 entries), thread-safe
- FormatCache.SharedDefault singleton preserves process-wide sharing
- FormatCache.EmptyCache for testing
- CompiledFormat sealed trait for type-safe opaque cache entries
- RuntimeFormat: direct Val dispatch, Long fast path, pre-cached specs
- PartialApplyFmt pre-parses at construction time (no cache needed)
- FormatCache threaded through Interpreter → Evaluator constructors
Upstream: he-pin/sjsonnet jit branch (format optimization commits)1 parent 3ff6d95 commit c0bc815
6 files changed
Lines changed: 317 additions & 104 deletions
File tree
- sjsonnet
- src-jvm-native/sjsonnet
- src/sjsonnet
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
376 | | - | |
| 376 | + | |
| 377 | + | |
377 | 378 | | |
378 | 379 | | |
379 | 380 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
1256 | 1257 | | |
1257 | 1258 | | |
1258 | 1259 | | |
1259 | | - | |
1260 | | - | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
1261 | 1263 | | |
1262 | 1264 | | |
1263 | 1265 | | |
| |||
0 commit comments