Skip to content

Cache round Linux camera crop runs - #3144

Merged
richiemcilroy merged 1 commit into
CapSoftware:mainfrom
kyzer1023:perf/linux-round-camera-crop-runs
Oct 24, 2026
Merged

richiemcilroy merged 1 commit into
CapSoftware:mainfrom
kyzer1023:perf/linux-round-camera-crop-runs

Conversation

@kyzer1023

@kyzer1023 kyzer1023 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Linux instant recordings use a round camera bubble by default. crop_camera only took the fast row-copy path when the mask was empty. A circle mask is not empty, so every pixel did a scalar copy and an f64 alpha multiply, and OverlayRunCache rebuilt those runs on every camera frame because it keyed on camera_generation.

This change builds opaque, edge, and transparent runs once from the mask and caches them by size and radius. Interior spans use copy_from_slice. Mirrored frames still reverse pixels inside each span. Frames that are not fully opaque stay on the scalar path. Square and Full shapes with a corner radius use the same mask runs.

Merged #2809 covered the empty-mask opaque path. This covers the default round mask.

Benchmark

Median of 101 iterations after 20 warmups. Release profile (opt-level = "s"). Round shape, opaque RGBA frame of that size. Before is the previous crop_camera on the same VM. After is cached_runs (runs built once outside the timer).

Size Before (ms) After (ms) Speedup
230 (default) 0.1642 0.0140 11.7x
324 0.3247 0.0252 12.9x
460 0.6536 0.0545 12.0x
648 1.3030 0.1537 8.5x

Hardware: Intel Xeon, family 6 model 207, 4 cores / 4 threads, KVM, AVX2 and AVX-512.

cargo test -p cap-recording --release --lib crop_run_timing_benchmark -- --ignored --nocapture

Test plan

  • cargo fmt -p cap-recording
  • cargo clippy -p cap-recording --release --lib --no-deps -- -D warnings
  • cargo test -p cap-recording --release --lib linux_camera:: (49 passed, 3 ignored)

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

Speeds up Linux camera crops by caching mask runs across camera frames.

  • Opaque shaped camera crops reuse mask runs and copy full spans in bulk.

Review was based on code inspection; tests were not run.

Reviews (1) · Last reviewed commit: "perf: cache round Linux camera crop runs" · Reviewed by Greptile

@kyzer1023

Copy link
Copy Markdown
Contributor Author

@greptileai review

@vercel

vercel Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

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.

2 participants