Skip to content

Rename maybeDecompressedStringAsNumber and propagate mayContainCompressedIds to non-leaf nodes#26980

Merged
CraigMacomber merged 5 commits intomicrosoft:mainfrom
CraigMacomber:mayContainCompressedIds
Apr 10, 2026
Merged

Rename maybeDecompressedStringAsNumber and propagate mayContainCompressedIds to non-leaf nodes#26980
CraigMacomber merged 5 commits intomicrosoft:mainfrom
CraigMacomber:mayContainCompressedIds

Conversation

@CraigMacomber
Copy link
Copy Markdown
Contributor

@CraigMacomber CraigMacomber commented Apr 9, 2026

Description

Improves clarity around how compressed ids are handled in UniformChunks, and tracks if a chunk might use them (deeply) in the shape.

As a memory optimization, avoid storing idCompressor when unneeded. For small leaf chunks (as is common currently) this should help memory use a little as there are a very large number of such chunks.

Reviewer Guidance

The review process is outlined on this wiki page.

@CraigMacomber CraigMacomber requested a review from a team as a code owner April 9, 2026 17:17
Copilot AI review requested due to automatic review settings April 9, 2026 17:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR clarifies and refines how UniformChunks represent and interpret ID-compressed values by renaming the leaf opt-in flag, introducing a derived mayContainCompressedIds signal for entire shapes, and using that signal to avoid retaining an idCompressor reference when it cannot be needed.

Changes:

  • Replaced the old leaf-only flag with a clearer leaf opt-in (maybeCompressedIdLeaf) and a derived shape-wide indicator (mayContainCompressedIds) that propagates from descendants.
  • Updated UniformChunk to only retain idCompressor when the chunk’s shape indicates compressed IDs may be present.
  • Updated/added tests to validate invalid flag usage and propagation of mayContainCompressedIds.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/dds/tree/src/feature-libraries/chunked-forest/uniformChunk.ts Adds mayContainCompressedIds, derives it from child shapes, updates cursor decompression logic, and conditionally retains idCompressor.
packages/dds/tree/src/feature-libraries/chunked-forest/chunkTree.ts Updates JSDoc around when UniformChunk compression applies.
packages/dds/tree/src/test/feature-libraries/chunked-forest/uniformChunk.spec.ts Switches to assertion-based failure validation and adds propagation tests for mayContainCompressedIds.

Comment thread packages/dds/tree/src/feature-libraries/chunked-forest/uniformChunk.ts Outdated
Comment thread packages/dds/tree/src/feature-libraries/chunked-forest/chunkTree.ts
Comment thread packages/dds/tree/src/feature-libraries/chunked-forest/uniformChunk.ts Outdated
Comment thread packages/dds/tree/src/feature-libraries/chunked-forest/uniformChunk.ts Outdated
Comment thread packages/dds/tree/src/feature-libraries/chunked-forest/uniformChunk.ts Outdated
Comment thread packages/dds/tree/src/test/feature-libraries/chunked-forest/uniformChunk.spec.ts Outdated
Comment thread packages/dds/tree/src/test/feature-libraries/chunked-forest/uniformChunk.spec.ts Outdated
Comment thread packages/dds/tree/src/test/feature-libraries/chunked-forest/uniformChunk.spec.ts Outdated
// Slow path: walk shape and cursor together, inserting values.
if (shape.hasValue) {
if (
shape.mayContainCompressedIds &&
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this "fix" is not as important as it might seem, since we do not support unions in uniform chunks currently, so this could never put a compressed id where a number is valid. Therefor there could have been no impacted users. With this change however, where we discard the id compressor, this change is required to ensure decode always works.

Co-authored-by: Joshua Smithrud <54606601+Josmithr@users.noreply.github.com>
Comment thread packages/dds/tree/src/feature-libraries/chunked-forest/uniformChunk.ts Outdated
…Chunk.ts

Co-authored-by: Joshua Smithrud <54606601+Josmithr@users.noreply.github.com>
@CraigMacomber CraigMacomber merged commit 3cd87ad into microsoft:main Apr 10, 2026
30 checks passed
@CraigMacomber CraigMacomber deleted the mayContainCompressedIds branch April 10, 2026 05:14
agarwal-navin pushed a commit to agarwal-navin/FluidFramework that referenced this pull request Apr 13, 2026
…ssedIds to non-leaf nodes (microsoft#26980)

## Description

Improves clarity around how compressed ids are handled in UniformChunks,
and tracks if a chunk might use them (deeply) in the shape.

As a memory optimization, avoid storing idCompressor when unneeded. For
small leaf chunks (as is common currently) this should help memory use a
little as there are a very large number of such chunks.
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.

3 participants