Skip to content

⚡️ Halve the Live Debugger's capture time for objects with many keys - #5217

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
mainfrom
watson/debugger-capture-list-keys-once
Nov 2, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
mainfrom
watson/debugger-capture-list-keys-once

Conversation

@watson

@watson watson commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

When the Live Debugger captures an object, it fetches the object's property names twice. captureObjectProperties fetches them to count the fields, then captureObjectPropertiesFields fetches them again to choose which fields to capture. Snapshots are correct and contain each field once: the duplicate is internal work, not output. This has been there since #4449.

Fetching the names builds an array of all the object's own property names, which gets slow for objects with many properties. It's a single built-in call, so the 10 ms capture deadline can't interrupt it. For an object with 100k string keys, fetching the names once (getOwnPropertyNames, getOwnPropertySymbols and the concat) takes about 34 ms in Chromium, 2 ms in Firefox and 8 ms in WebKit (headless Playwright on a Neoverse N1 CPU).

This affects every snapshot, not only Exception Replay: probe captures on entry, return and throw, and capture expressions.

Changes

Fetch the property names once in captureObjectProperties and pass them to captureObjectPropertiesFields. captureFields, used for arguments and locals, still fetches its own. Snapshots don't change.

Capturing a 100k-key object as a function argument in Chromium:

Before After
Warm median (50 runs) 69 ms 35 ms
Cold, 10 ms deadline (times out in both) 71 ms 37 ms

Test instructions

Run yarn test:unit --spec packages/browser-debugger/src/domain/capture.spec.ts. The existing tests cover the captured output, including size and fieldCount.

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

🤖 Generated with Claude Code

captureObjectProperties listed an object's own keys to compute the
field count, then captureObjectPropertiesFields listed them again to
pick the fields to capture. Each listing is one built-in call that the
capture deadline can't interrupt. For an object with 100k keys it takes
about 34 ms in Chromium.

List the keys once and pass them to captureObjectPropertiesFields.
captureFields still lists its own.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@watson
watson requested review from a team as code owners October 31, 2026 12:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T07:57:37.952408Z cfa6880 New commits
🔒 Security Review ✅ Completed 2026-11-02T07:58:54.338706Z cfa6880 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 190.87 KiB 190.87 KiB 0 B 0.00% ✅
Rum 190.84 KiB 190.84 KiB 0 B 0.00% ✅
Rum Salesforce Profiler 8.35 KiB 8.35 KiB 0 B 0.00% ✅
Rum Profiler 8.35 KiB 8.35 KiB 0 B 0.00% ✅
Rum Salesforce Recorder 32.04 KiB 32.04 KiB 0 B 0.00% ✅
Rum Recorder 32.04 KiB 32.04 KiB 0 B 0.00% ✅
Logs 59.78 KiB 59.78 KiB 0 B 0.00% ✅
Rum Slim 146.99 KiB 146.99 KiB 0 B 0.00% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 221.29 KiB 221.29 KiB 0 B 0.00% ✅
Rum Shopify Profiler 8.35 KiB 8.35 KiB 0 B 0.00% ✅
Rum Shopify Recorder 4.85 KiB 4.85 KiB 0 B 0.00% ✅

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 77.30% (-0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: cfa6880 | Docs | View more details | Give us feedback!

@datadog-prod-us1-5 datadog-prod-us1-5 Bot 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.

Bits Code Review: PASS

More details

Reusing the key list preserves string/symbol ordering and field-limit output while eliminating duplicate enumeration. Runtime behavior remains unverified because dependencies are not installed.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit ce782bc

watson and others added 2 commits October 31, 2026 14:01
It checked calls to built-in functions rather than output. The existing
"should truncate objects with many fields" test already covers size and
fieldCount.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Environment: Datadog workspace

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@etayyosefdd etayyosefdd 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.

LGTM 👍

@watson

watson commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-11-01 18:51:39 UTC ℹ️ Start processing command /merge


2026-11-01 18:51:44 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 20m (p90).


2026-11-01 19:09:22 UTC ❌ MergeQueue: The build pipeline failed for this merge request

Build pipeline has failing jobs for 2dc414f:

⚠️ Do NOT retry failed jobs directly (why?).

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.

watson commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-11-02 08:11:32 UTC ℹ️ Start processing command /merge


2026-11-02 08:11:36 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 20m (p90).


2026-11-02 08:28:23 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit ffcdf90 into main Nov 2, 2026
32 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the watson/debugger-capture-list-keys-once branch November 2, 2026 08:28
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants