Avoid rebuilding consecutive particle system UUID strings - #274
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 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
systemUuidindecodeParticleRenderOutput, 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 = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
git diff --checkpassed.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.