Skip to content

perf(desktop-gpui): keep the edge-column branch out of the thumbnail box loop - #3185

Merged
richiemcilroy merged 2 commits into
CapSoftware:mainfrom
Markgatcha:perf/thumbnail-box-column
Oct 25, 2026
Merged

richiemcilroy merged 2 commits into
CapSoftware:mainfrom
Markgatcha:perf/thumbnail-box-column

Conversation

@Markgatcha

@Markgatcha Markgatcha commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

On Windows and Linux, capture_target_thumbnail grabs a full-resolution screenshot and hands it to fit_centered_capture to build the picker card. That fits by box-averaging the source down by a whole factor first and letting Lanczos finish the fit. For a 1440p display the box pass was about 25ms of the 66ms the thumbnail took, and almost all of it was per-pixel overhead rather than arithmetic.

The loop made two decisions that only depend on the column, but made them for every pixel: which BlockDivisor to divide by (if index + 1 == reduced_width), and where the source block starts (columns.chunks(factor * CHANNELS)). Only the last column averages a short block, so it can take its own divisor outside the loop, and every other block is just index * factor * CHANNELS. Splitting the last column out and indexing directly is 2.8x on that phase in isolation, with byte-identical output.

Whole fit, medians of three interleaved builds per side:

capture before after speedup
2560x1440 63.7 ms 34.4 ms 1.69x
3440x1440 80.4 ms 42.7 ms 1.66x
3840x2160 68.5 ms 46.0 ms 1.49x
5120x2880 77.4 ms 56.8 ms 1.39x
3840x2160 window 72.0 ms 57.0 ms 1.39x
1920x1080 45.7 ms 44.6 ms unchanged

1080p can't move: prescale_factor comes out below 2 at that size, so it never enters box_downscale.

cargo test -p cap-gpui-kernels passes. box_downscale_averages_blocks_and_keeps_partial_edges recomputes the expected block averages by hand, including the short edge blocks that this loop now handles separately, and capture_fit_stays_within_tight_bounds_of_the_exact_fit covers the fitted output.

One note on method, since it decides whether the table is worth anything: this machine drifts between builds. The same unchanged 1440p capture measured 61.6ms in one pair and 63.7ms in the next, and the bench's own control column moved by up to 20% between rebuilds. So each row is a rebuild of main followed by a rebuild of this branch, three times over, with the speedup taken as the median of the three and each side normalised against the image crate column that benches/thumbnail_capture.rs measures in the same run.

RetriggerView in GreptileConfidence Score: 5/5

This PR appears safe to merge; no actionable issues were found.

Summary

Speeds up box_downscale by handling the final column separately and moving the shared sum loop into block_sums.

  • Large capture thumbnails skip edge checks inside the pixel loop.

Reviews (1) · Last reviewed commit: "perf(desktop-gpui): keep the edge-column..." · Reviewed by Greptile

Copilot AI balanced review requested due to automatic review settings October 25, 2026 04:10
@vercel

vercel Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

@Markgatcha is attempting to deploy a commit to the Cap Software Inc Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 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 ⚠️ Failed 2026-10-25T04:11:58.025316Z
We couldn’t complete this review. Comment @codex review to try again.
dd73afc PR opened
ℹ️ 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.

Copilot AI balanced review requested due to automatic review settings October 25, 2026 05:37

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@richiemcilroy
richiemcilroy merged commit 67cb2b9 into CapSoftware:main Oct 25, 2026
51 of 55 checks passed
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