Skip to content

perf: skip discarded CDP logs and duplicate locator setup - #3128

Open
antonvishal wants to merge 4 commits into
browserbase:mainfrom
antonvishal:vishal/perf-cdp-locator-overhead
Open

antonvishal wants to merge 4 commits into
browserbase:mainfrom
antonvishal:vishal/perf-cdp-locator-overhead

Conversation

@antonvishal

@antonvishal antonvishal commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Why

Local billing runs used about 8% less browser CPU time and finished about 6.4% sooner.

Metric Stagehand before Playwright This PR
Wall time 11.44 s 16.61 s 10.70 s
Flow p50 255 ms 456 ms 232 ms
Session p50 317 ms 484 ms 289 ms
Browser CPU seconds 50.82 39.33 46.76
Peak browser RSS 5,693 MB 4,443 MB 5,602 MB
Failures 0/384 0/384 0/384

Medians of three local runs, each with 128 billing flows and four reused browsers. No LLM calls.

Discarded CDP logs still serialized data and created spans. Locator actions repeated domain setup, and fill resolved the same input twice.

What

Skip work for discarded logs, remove unused retained data, reuse successful internal Runtime/DOM setup, and fill using the original input handle. Resolve a replacement input once if the page swaps it.

Raw CDP calls still dispatch normally. Failed enables and explicit disables invalidate the cache. Failed fill preparation rejects; suppressed logs no longer create spans. Enabled debug logs and operation spans remain.

How

1,181 extension/TypeScript tests and 23 browser integration tests passed. Builds and extension typecheck passed.


Summary by cubic

Reduces per-action CDP overhead. Across three local runs of 128 billing flows, median wall time fell from 11.44 to 10.70 seconds and browser CPU time from 50.82 to 46.76 seconds, with all 384 flows passing.

Discarded CDP logs now shortcut StagehandLogger before serialization or span creation. Successful internal domain setup is cached and reused across locator calls, and fill prepares its original input handle, retrying once when the page swaps the element. Cached setup is invalidated on failed enable or explicit Runtime.disable/DOM.disable. The Go SDK's embedded extension bundle was rebuilt to match the protocol version.

Behavior changes

  • fill now rejects when a replacement input also fails preparation, instead of falling back to typing into whatever focus is active.
  • Suppressed log records no longer create tracing spans; enabled debug logs and operation spans are unchanged.

Written for commit e1cde8c. Summary will update on new commits.

View guided diff

@changeset-bot

changeset-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e1cde8c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-go Patch
@browserbasehq/stagehand-python Patch
@browserbasehq/stagehand-extension Patch
browse Patch
@browserbasehq/stagehand-examples Patch
@browserbasehq/stagehand-integrations-claude-cua-sdk Patch
@browserbasehq/stagehand-integrations Patch
@browserbasehq/eve Patch
@browserbasehq/stagehand-integrations-gemini-cua-sdk Patch
@browserbasehq/stagehand-integrations-example-pi-facade Patch
@browserbasehq/stagehand-integrations-claude-agent-sdk Patch
@browserbasehq/stagehand-integrations-example-claude-code-facade Patch
@browserbasehq/stagehand-integrations-codex-sdk Patch
@browserbasehq/stagehand-integrations-example-codex-facade Patch
@browserbasehq/stagehand-integrations-cursor-sdk Patch
@browserbasehq/stagehand-integrations-example-cursor-facade Patch
@browserbasehq/stagehand-integrations-deepagents-sdk Patch
@browserbasehq/stagehand-integrations-eve-sdk Patch
@browserbasehq/stagehand-integrations-fx-sdk Patch
@browserbasehq/stagehand-integrations-mastra-sdk Patch
@browserbasehq/stagehand-integrations-example-mastra-facade Patch
@browserbasehq/stagehand-integrations-pi-sdk Patch
@browserbasehq/stagehand-integrations-example-vercel-ai-facade Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run.
Approving the latest commit mirrors it into an internal PR owned by the approver.
If new commits are pushed later, the internal PR stays open but is marked stale until someone approves the latest external commit and refreshes it.

@github-actions github-actions Bot added external-contributor Tracks PRs mirrored from external contributor forks. external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Oct 7, 2026
@antonvishal
antonvishal marked this pull request as ready for review October 7, 2026 15:57
…ator-overhead

# Conflicts:
#	packages/sdk-go/internal/extensionassets/stagehand-extension.zip
…erf-cdp-locator-overhead

# Conflicts:
#	packages/sdk-go/internal/extensionassets/stagehand-extension.zip

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant