Skip to content

♻️ [PANA-5948] Make some small improvements to ItemId management#4164

Merged
sethfowler-datadog merged 1 commit intomainfrom
seth.fowler/PANA-5948-make-small-improvements-to-itemid-management
Feb 13, 2026
Merged

♻️ [PANA-5948] Make some small improvements to ItemId management#4164
sethfowler-datadog merged 1 commit intomainfrom
seth.fowler/PANA-5948-make-small-improvements-to-itemid-management

Conversation

@sethfowler-datadog
Copy link
Contributor

Motivation

Change records are a new, experimental data format for session replay data that's designed to record the same information in a more compact, more compressible form.

We've already landed support for recording full snapshots as Change records behind an experiment flag. The next step is to introduce support for incremental snapshots, as well. This requires making improvements to a number of different aspects of the recording code. This PR is the second in a series that will work toward the goal of supporting incremental snapshots; for the previous PR, see #4163.

Changes

This PR makes some small improvements to the code surrounding the ItemIds interface, which is used to track the identifiers assigned to various kinds of DOM-related objects during recording.

In particular:

  1. A delete() method has been added, making it possible to delete an item id. This allows you to reinsert the same item and assign it a new id, which is something that the new serialization algorithm requires.
  2. A nextId getter has been added, making it possible to determine what the next item id will be before actually assigning it. This, too, is helpful for implementing the new serialization algorithm.
  3. The existing clear() method now does nothing if no ids have been assigned. This is just a small performance optimization.

Related code has been updated:

  1. In startFullSnapshots.ts, we now always call scope.resetIds() when generating a Change record, regardless of whether we're generating the initial full snapshot or a subsequent one. We avoided calling it for the first full snapshot as a small performance optimization, but now ItemIds#clear() avoids the unnecessary work automatically.
  2. In recordingScope.ts, the implementation of scope.resetIds() now calls clear() on the ItemIds instances that are currently stored on the RecordingScope, instead of just the ones that were passed in when the RecordingScope was constructed. This is helpful for testing the new serialization algorithm, since it allows us to wrap these ItemIds instance in test code with version that check assertions.
  3. Tests have been added for the new methods. (The behavior change in clear() is not visible, so there's no test, but the existing tests continue to pass.)

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

Copy link

@Tizi42 Tizi42 left a comment

Choose a reason for hiding this comment

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

Looks good. The PR description was helpful, thanks!

Base automatically changed from seth.fowler/PANA-5945-support-child-list-insertioncursors to main February 12, 2026 16:44
@sethfowler-datadog sethfowler-datadog force-pushed the seth.fowler/PANA-5948-make-small-improvements-to-itemid-management branch from c087d1a to 2b859b3 Compare February 12, 2026 16:46
@cit-pr-commenter-54b7da
Copy link

cit-pr-commenter-54b7da bot commented Feb 12, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 169.43 KiB 169.43 KiB 0 B 0.00%
Rum Profiler 4.29 KiB 4.29 KiB 0 B 0.00%
Rum Recorder 24.61 KiB 24.71 KiB +94 B +0.37%
Logs 56.72 KiB 56.72 KiB 0 B 0.00%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 126.26 KiB 126.26 KiB 0 B 0.00%
Worker 23.63 KiB 23.63 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.004 0.0046 +15.00%
RUM - add action 0.0137 0.0166 +21.17%
RUM - add error 0.0132 0.0149 +12.88%
RUM - add timing 0.0028 0.0031 +10.71%
RUM - start view 0.0128 0.0179 +39.84%
RUM - start/stop session replay recording 0.0007 0.0008 +14.29%
Logs - log message 0.0151 0.0188 +24.50%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 27.30 KiB 27.66 KiB +371 B
RUM - add action 50.78 KiB 51.23 KiB +460 B
RUM - add timing 26.54 KiB 26.59 KiB +50 B
RUM - add error 57.73 KiB 56.60 KiB -1.13 KiB
RUM - start/stop session replay recording 26.09 KiB 26.13 KiB +45 B
RUM - start view 454.18 KiB 453.15 KiB -1.03 KiB
Logs - log message 46.38 KiB 45.63 KiB -773 B

🔗 RealWorld

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Feb 12, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 90.91%
Overall Coverage: 77.30% (+0.01%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2b859b3 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@sethfowler-datadog sethfowler-datadog merged commit 29c721c into main Feb 13, 2026
21 checks passed
@sethfowler-datadog sethfowler-datadog deleted the seth.fowler/PANA-5948-make-small-improvements-to-itemid-management branch February 13, 2026 17:36
@github-actions github-actions bot locked and limited conversation to collaborators Feb 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants