Skip to content

Phase 4.0 Cache Checkpoint - Summary

Status

Phase 4.0 checkpoint: ✅ Complete

Decision: No runtime cache change proposed

Comprehensive validation: ❌ Not complete


Core Decision

No per-style Cell cache capacity or eviction change is justified by the currently measured synthetic workloads.

Keep unchanged:

  • MAX_CACHED_CELLS_PER_STYLE = 128
  • Clear-all eviction policy
  • No LRU/LFU implementation

Rationale: Insufficient evidence to justify modification, not proof of optimality.


What Was Measured

  • 8 synthetic profiler workloads
  • Cell cache hit rates and bucket distribution
  • Text cache behavior (limited coverage)
  • Wrap cache width-bucket behavior
  • Grapheme timing (advisory, single-run)

Key Findings

Per-Style Cell Capacity

  • Decision: No change justified
  • Data: Repeated CJK 99.98% hit, Mixed 37.49% hit, 0 clears
  • Limitation: Mixed uses fresh Style per line (sharded), doesn't validate reused styles

Eviction Strategy

  • Decision: Inconclusive
  • Limitation: No post-clear reuse workload

Text Cache Sizing

  • Decision: Inconclusive
  • Limitation: 1000 < MAX 1024, capacity not exercised

Wrap Cache

  • Decision: Per-width capacity not measured
  • Data: Outer width-bucket instrumentation validated

Grapheme

  • Decision: Not measured with decision-grade timing
  • Conclusion: Inconclusive (counter coverage confirmed; no isolated segmentation benchmark)

Long Text / inlineLineCache

  • Decision: Not measured

Style Cardinality

  • Decision: Not measured (registered ≠ live)

Critical Limitations

Measurement Issues

  • Heap measurements invalid for retained-memory analysis (excluded from decisions)
  • Registered buckets ≠ live production buckets
  • Mixed workload artificially sharded (fresh Style per line)

Coverage Gaps

  • No reused style with >128 characters
  • No eviction-sensitive workload
  • No capacity threshold testing
  • No long text scenarios
  • No production traces

What Is NOT Claimed

❌ Current cache is validated ❌ Current cache performs well (globally) ❌ 90%+ safety margin for reused styles ❌ Segmentation is cheap ❌ Text/wrap sizing is adequate ❌ All gates failed ❌ Cache work complete


Next Steps

Required: Phase 3 Disabled-Path Overhead Validation

This is mandatory and independent of cache-tuning decisions.

Phase 3 instrumentation hooks are in production hot paths (createCell, textCellWidth, wrapByCells). The disabled-path production overhead must be validated.

Compare:

  • Pre-Phase-3 commit (before PR #116)
  • Current main with instrumentation disabled

Requirements:

  • Isolated processes or separate worktrees
  • Randomized/alternating execution order
  • Warmup + multiple samples
  • p50/p95 comparison with confidence intervals
  • Use Phase 2 baseline harness

Tracked in #119.


Optional: Phase 4.1 Cache Workload Validation

Phase 4.1 is optional only if cache optimization is explicitly deferred.

Required before:

  • Claiming cache strategy is validated
  • Changing cache capacity or eviction
  • Closing cache evaluation as complete

If pursued, add:

  • Stable style + high diversity + multiple passes
  • Eviction-sensitive patterns
  • Capacity threshold tests
  • Long text scenarios
  • Production traces

Conclusion

Phase 4.0 is a checkpoint, not comprehensive validation.

Engineering decision: Keep implementation unchanged due to insufficient evidence for change.

Not a validation that current cache is optimal or adequate for all scenarios.

Bug reports, feature requests, and documentation issues are tracked on GitHub Issues.