Repository navigation
perf(gpui): halve 4K screenshot blur peak allocations with a row buffer - #3343
Draft
Reet24-del wants to merge 1 commit into
Draft
Reet24-del wants to merge 1 commit into
Reet24-del wants to merge 1 commit into
Conversation
Contributor
|
@Reet24-del is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
Screenshot blur masks currently allocate every vertically filtered row before horizontally sampling them. Reuse one scratch row and immediately write its horizontally filtered pixels into the output. This preserves vertical-then-horizontal sampling, tap accumulation order, both horizontal paths and rounding, while reducing temporary allocations in GPUI screenshot previews and exports.
For a full 3840×2160 blur at level 16, measured peak live allocation requests during the complete filter drop from 65.503 MiB to 33.877 MiB (48.3% less). This includes the small intermediate image, final output and weight tables, but excludes the preallocated input. It is not process RSS. The two 31.64 MiB vertical scratch allocations run sequentially; their replacements are 60 KiB and 15 KiB.
This follows merged #2979, using its implementation as the baseline. Unchanged masks are already cached; the saving applies when a blur mask actually needs filtering.
Measurements
Apple M5, 16 GB RAM, macOS 26.5.2, arm64; Rust 1.88.0, image 0.25.10, opt-level 3, thin LTO and one codegen unit. Baseline
fb453e3e3032f8b976378cd477e676eeb32f7bbc, candidate1d4067138213c531a276f564c35edd0e3a222ce9. The baseline screenshot source is identical to the original investigation commitf6046f1ec82314b0aa887b76bc1ebf8bc77e3579.Five independent process runs. Each workload asserts full output-image equality, discards three warmup pairs and records 21 samples with alternating execution order. Timings include the complete filter and output destruction, but exclude fixture creation and equality assertions. Tracking is disabled during timings; a separate allocator probe records peak requested live bytes for each implementation and verifies that all tracked bytes are freed. The table reports medians of the five process medians and the median of the five paired speedup ratios.
Memory reduction is the main result. Timing improvements are modest. Tiny masks are near timing noise; one 1080p/level-40 process regressed by about 1.2%, while its median paired result was 1.007×. No native UI responsiveness or whole-app RSS improvement is claimed.
Validation and remaining checks
cidrebecausexcodebuildrequires full Xcode; this Mac currently has Command Line Tools only. The app has not been built or launched. The actual changed source passed the 27 isolated tests on both Rust 1.88.0 and 1.95.0 with image 0.25.10; this remains distinct from full-workspace/native validation.Standalone before/after benchmark source and reproduction commands
Run from a checkout containing both revisions. These commands pin image 0.25.10 but resolve transitive dependencies afresh. The exact measured image dependency versions were: adler2 2.0.1, autocfg 1.5.1, bitflags 2.13.2, bytemuck 1.25.2, byteorder-lite 0.1.0, cfg-if 1.0.5, crc32fast 1.5.3, fdeflate 0.3.7, flate2 1.1.10, image 0.25.10, image-webp 0.2.4, miniz_oxide 0.8.9, miniz_oxide 0.9.1, moxcms 0.8.1, num-traits 0.2.19, png 0.18.1, pxfm 0.1.30, quick-error 2.0.1, simd-adler32 0.3.10, zlib-rs 0.6.8, zune-core 0.5.3, zune-jpeg 0.5.15.