Skip to content

improvement(tree): Maintain column/row ID -> node cache for faster lookup#27236

Merged
Josmithr merged 3 commits intomicrosoft:mainfrom
Josmithr:tree/table/row-column-id-cache
May 6, 2026
Merged

improvement(tree): Maintain column/row ID -> node cache for faster lookup#27236
Josmithr merged 3 commits intomicrosoft:mainfrom
Josmithr:tree/table/row-column-id-cache

Conversation

@Josmithr
Copy link
Copy Markdown
Contributor

@Josmithr Josmithr commented May 5, 2026

This was identified as a key bottleneck in some consumer scenarios. Caching the ID -> node mapping saves an O(n) lookup for each operation.

@Josmithr Josmithr requested review from Copilot and jumyhre May 5, 2026 22:55
@Josmithr Josmithr requested a review from a team as a code owner May 5, 2026 22:55
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Hi! Thank you for opening this PR. Want me to review it?

Based on the diff (270 lines, 2 files), I've queued these reviewers:

  • Correctness — logic errors, race conditions, lifecycle issues
  • Security — vulnerabilities, secret exposure, injection
  • API Compatibility — breaking changes, release tags, type design
  • Performance — algorithmic regressions, memory leaks
  • Testing — coverage gaps, hollow tests

How this works

  • Adjust the reviewer set by ticking/unticking boxes above. Reviewer toggles alone don't trigger anything.

  • Tick Start review below to dispatch the review fleet.

  • After review finishes, tick Start review again to request another run — it auto-resets after each dispatch.

  • This comment updates as new commits land; your reviewer selections are preserved.

  • Start review

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 optimizes TableSchema row/column lookups by replacing repeated linear scans with lazily built ID→node caches inside the table implementation. It fits into the tree table API as a performance improvement for getCell, setCell, and other APIs that resolve rows/columns by string ID.

Changes:

  • Add lazy row and column ID lookup caches to TableSchema.Table.
  • Invalidate those caches from nodeChanged listeners on the row/column arrays.
  • Route #tryGetRow and #tryGetColumn string-ID lookups through the caches instead of Array.find.

Comment thread packages/dds/tree/src/tableSchema.ts
Comment thread packages/dds/tree/src/tableSchema.ts
Comment thread packages/dds/tree/src/tableSchema.ts
@Josmithr Josmithr enabled auto-merge (squash) May 6, 2026 20:39
@Josmithr Josmithr merged commit 446525e into microsoft:main May 6, 2026
31 checks passed
@Josmithr Josmithr deleted the tree/table/row-column-id-cache branch May 6, 2026 21:02
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