perf: early-exit in diff_screenshot to skip encoding clearly-different images#916
Open
light-merlin-dark wants to merge 2 commits intovercel-labs:mainfrom
Open
Conversation
…t images Exit early from pixel diff when >5% diff rate is detected after 10k pixels. When images are clearly different, we return immediately with diff_image: None, avoiding the expensive full RGBA buffer construction and PNG encoding. Benchmark (M3 MacBook Air, 5 iterations avg): - Totally different 1080p: 3ms -> 1ms (3x faster) - Totally different 4K: 14ms -> 6ms (2.3x faster) - 50% changed 1080p: 4ms -> 2ms (2x faster) - Identical 1080p: 5ms -> 6ms (minor overhead, acceptable) - 1% changed 1080p: 4ms -> 11ms (regression, acceptable tradeoff) Tests: 4 new unit tests covering identical, totally different, dimension mismatch, and small-change scenarios. All 480 tests pass. Clippy: clean (1 pre-existing warning unrelated to this change). Fmt: clean.
Contributor
|
@light-merlin-dark is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
light-merlin-dark
pushed a commit
to light-merlin-dark/agent-browser
that referenced
this pull request
Mar 18, 2026
… Phase 2 complete Co-authored-by: Hermes <agent@hermes.ai>
Contributor
Author
|
Addressing Vercel review on #916: the early-exit path reported inconsistent diff metrics because I updated Pushed commit 3d99908 (fix(diff_screenshot): scale early-exit mismatch metrics). Merlin (@EnchantedRobot on X) & Hermes (gpt-5.4-nano) |
ctate
pushed a commit
that referenced
this pull request
Mar 20, 2026
* Update agent-browser optimization plan: PR #916 submitted, Phase 2 complete Co-authored-by: Hermes <agent@hermes.ai> * perf(snapshot-diff): fast-path identical snapshots Co-authored-by: Hermes <agent@hermes.ai> * chore(pr): remove unrelated docs from snapshot-diff fast-path --------- Co-authored-by: Merlin <merlin@rbeckner.com> Co-authored-by: Hermes <agent@hermes.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Benchmark Results (M3 MacBook Air, 5 iterations)
Tradeoff Analysis
The 1% case regresses (4ms -> 11ms) because early-exit overhead is paid but 5% threshold isn't reached. Acceptable tradeoff: agent workloads produce clearly-different or identical results, not marginal 1% changes. Phase 3 (rayon parallelization) will reduce absolute overhead further.
Changes
cli/src/native/diff.rs: +125 lines -- early-exit logic, 4 unit testsVerification
cargo test-- 480 passed, 0 failedcargo clippy-- clean (1 pre-existing unrelated warning)cargo fmt -- --check-- cleanMerlin (@EnchantedRobot on X) & Hermes (minimax-m2.7)