Skip to content

perf(render): reuse stable session layouts#114

Merged
Arbousier1 merged 1 commit into
devfrom
codex/perf-session-layout-cache
Jul 18, 2026
Merged

perf(render): reuse stable session layouts#114
Arbousier1 merged 1 commit into
devfrom
codex/perf-session-layout-cache

Conversation

@TypeThe0ry

Copy link
Copy Markdown
Member

What changed

  • Adds a thread-safe, single-entry exact layout cache per table session.
  • Keys every field read by layout generation, including center, variant, wall/dora/open-door state, seat hand selections, discards, melds, riichi, and sticks.
  • Reuses immutable center, unchanged seat plans, and wall/dora components on partial changes.
  • Keeps the original cold precompute implementation intact.
  • Adds dependency-by-dependency cache invalidation tests and JMH scenarios.

Why

Stable refreshes rebuilt the same immutable layout objects, allocating roughly 31–36 KB per operation.

Impact

The cache is internal to a table session. Layout values, entity placement, public APIs, and rendering behavior remain unchanged.

Evidence

  • stable hit: about 186 ns/op with effectively zero allocation
  • seat-only miss: about 1.85 µs and 17.9 KB/op
  • wall-only miss: about 1.56 µs and 9.6 KB/op
  • eight-pair cold-path guardrail found no statistically significant regression

Validation

  • SessionRenderLayoutCacheTest
  • jmhJar
  • spotlessCheck
  • full integration test suite passed before commit splitting

@Arbousier1
Arbousier1 force-pushed the codex/perf-session-layout-cache branch from 4b54cdb to c9a82f6 Compare July 18, 2026 12:58
@Arbousier1 Arbousier1 added performance-layout-cache Use the session layout cache performance profile performance-ab Run the base-owned paired performance gate and removed performance-ab Run the base-owned paired performance gate performance-layout-cache Use the session layout cache performance profile labels Jul 18, 2026
@Arbousier1

Copy link
Copy Markdown
Collaborator

Formal trusted A/B passed with PASS_OPTIMIZED. Evidence: https://github.com/EllanServer/MahjongEngine/actions/runs/29645452299.

@Arbousier1
Arbousier1 marked this pull request as ready for review July 18, 2026 13:19
@Arbousier1
Arbousier1 merged commit 49d4d2d into dev Jul 18, 2026
20 of 25 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants