Repository navigation
perf(gpui): SIMD vectorize rgba_to_rgb and eliminate image conversion overhead - #2672
nikolas-sapa wants to merge 2 commits into
Conversation
|
@nikolas-sapa is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
| } | ||
| } | ||
|
|
||
| // Portable 4-pixel chunk unrolled fallback |
There was a problem hiding this comment.
The new // Portable 4-pixel chunk unrolled fallback comment only describes the loop below it. The repository guide explicitly bans comments that narrate what the code does. Remove it before merging to meet that requirement.
| // Portable 4-pixel chunk unrolled fallback |
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/kernels/src/codec.rs
Line: 45
Comment:
**Comment repeats the code**
The new `// Portable 4-pixel chunk unrolled fallback` comment only describes the loop below it. The repository guide explicitly bans comments that narrate what the code does. Remove it before merging to meet that requirement.
```suggestion
```
**Context Used:** AGENTS.md ([source](https://github.com/capsoftware/cap/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| let rgb = rgba_to_rgb(rgba.as_raw()); | ||
| encode_jpeg_rgb(&rgb, rgba.width(), rgba.height(), quality) |
There was a problem hiding this comment.
JPEG test compares identical paths
Routing encode_jpeg_rgba_as_rgb through encode_jpeg_rgb makes jpeg_paths_agree_on_the_same_pixels compare the same conversion and encoder calls with themselves. It no longer checks that this replacement preserves the old JPEG output. Keep an independent reference in the test using ConvertBuffer and encode_image, then compare it with the new path.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/kernels/src/codec.rs
Line: 127-128
Comment:
**JPEG test compares identical paths**
Routing `encode_jpeg_rgba_as_rgb` through `encode_jpeg_rgb` makes `jpeg_paths_agree_on_the_same_pixels` compare the same conversion and encoder calls with themselves. It no longer checks that this replacement preserves the old JPEG output. Keep an independent reference in the test using `ConvertBuffer` and `encode_image`, then compare it with the new path.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.…rence and remove comment
Summary
rgba_to_rgbinapps/desktop-gpui/kernels/src/codec.rsusing aarch64 NEON SIMD (vld4q_u8+vst3q_u8), processing 16 pixels (64 bytes in -> 48 bytes out) per iteration.chunks_exact(4).flat_map(...).collect().encode_jpeg_rgba_as_rgbto callrgba_to_rgbdirectly instead ofrgba.convert(), saving memory allocation and redundant pixel traversal during JPEG thumbnail and export encoding.benches/rgba_to_rgb.rs.Benchmark Results (Apple Silicon M-series)
thumbnail-320x180preset-216x122screen-720pscreen-1080pscreen-retinascreen-4kTest Plan
cargo test --manifest-path apps/desktop-gpui/kernels/Cargo.tomlcargo bench --manifest-path apps/desktop-gpui/kernels/Cargo.toml --bench rgba_to_rgbRemove the narrating comment before merging to meet the repository guide; the independent JPEG reference test is a non-blocking improvement.
Findings
Fix with agent prompt
Summary
Speeds up
rgba_to_rgbwith NEON on ARM and an unrolled fallback elsewhere.Review was based on code inspection; tests and benchmarks were not run.
Reviews (1) · Last reviewed commit: "perf(gpui): SIMD vectorize rgba_to_rgb a..." · Reviewed by Greptile