Skip to content

Avoid rebuilding consecutive particle system UUID strings - #274

Merged
Hona merged 2 commits into
mainfrom
work/tf2-koth-sustained-gc
Sep 1, 2026
Merged

Hona merged 2 commits into
mainfrom
work/tf2-koth-sustained-gc

Conversation

@Hona

@Hona Hona commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Change

Reuse the previous immutable system UUID string within one particle-output decode when all 128 bits match. Consecutive particles from the same PCF system no longer each build the same hexadecimal string with sixteen concatenations.

The cache holds one packet-local offset and string. It introduces no global cache or returned byte views, and preserves output values, ordering, validation, geometry and lifetime ownership.

Checks

  • Particle adapter tests: 11 passed, 41 assertions.
  • Covers changes in every UUID byte, repeated/alternating identity runs, complete-item equivalence, unaligned input, empty packets and retained output after input mutation.
  • git diff --check passed.

Performance scope

This narrow allocation-reduction candidate follows the recorded GC/long-frame investigation. Frame-time and input-tail gains remain unmeasured; this PR does not claim that gameplay stutter is resolved. No new browser capture, Windows task, production change or broad profiler rewrite is included.

Copilot AI lite review requested due to automatic review settings September 1, 2026 02:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is localized, preserves output semantics with full 128-bit comparisons, and is backed by focused tests for correctness and retention behavior.

Pull request overview

This PR optimizes decodeParticleRenderOutput by reusing the previously computed system UUID string when consecutive particle records contain the same 128-bit UUID, reducing repeated string building during packet decode.

Changes:

  • Added a packet-local cache for systemUuid in decodeParticleRenderOutput, with a full 128-bit equality check across consecutive records.
  • Updated particle adapter tests to cover UUID reuse correctness, alternating UUID runs, and retained decoded values after input mutation.
File summaries
File Description
packages/presentation/particle/src/index.ts Adds packet-local UUID string reuse based on 128-bit equality to avoid repeated hex-string construction for consecutive particles.
packages/presentation/particle/tests/particle.test.ts Adds targeted tests validating UUID caching behavior, alternating UUID runs, unaligned packets, and retained decoded output.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +180 to +183
// Consecutive particles commonly belong to one PCF system (notably weather).
// Its immutable UUID does not need sixteen new string concatenations for
// every particle. Compare all 128 bits; keep only this packet's last identity.
let identityOffset = -1, systemUuid = ""
@Hona
Hona merged commit db3a0ca into main Sep 1, 2026
2 checks passed
@Hona
Hona deleted the work/tf2-koth-sustained-gc branch September 1, 2026 02:34
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