Conversation
Optimize the hot paths in VNC and ZRLE decoding by replacing expensive integer division, modulo, and repeated multiplications in pixel-processing loops with incremental counters and row-base tracking. - Refactor `ZrleDecoder` to promote `ZInput` to a persistent member, ensuring the 16KB decompression buffer is reused across rectangles and reducing GC pressure. - Update `decodeTile` signature to accept a pre-calculated `tileRowBase`. - Eliminate division and modulo from ZRLE Plain RLE and Palette RLE decoding by manually tracking row and column indices. - Implement incremental `rowBase` tracking for RAW and CopyRect encodings in `VncClient.kt`. - Use `java.util.Arrays.fill` for bulk pixel operations where applicable. On mobile ARM architectures, these changes significantly reduce CPU cycles spent on arithmetic, leading to smoother framebuffer updates and lower latency in the X11 viewer. Co-authored-by: kimocoder <4252297+kimocoder@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
⚡ Bolt: Optimize VNC and ZRLE decoders with strength reduction
This PR implements several performance optimizations for the VNC and ZRLE decoders to improve the efficiency of the X11 viewer.
💡 What:
/), modulo (%), and repeated multiplications ((y + row) * stride + x) in tight pixel-processing loops with incrementalrowBaseandcurrColcounters.ZInputto a member ofZrleDecoderto ensure its 16KB internal decompression buffer is reused for the lifetime of the decoder, significantly reducing GC pressure.decodeTileto accept a pre-calculatedtileRowBaseto eliminate redundant arithmetic in the tile loop.ENC_COPY_RECTwith incremental tracking for both forward and backward copy directions.🎯 Why:
Integer division and modulo are notoriously slow on mobile ARM processors (costing 20-80 cycles vs 1 cycle for addition). By eliminating these from the hot path of framebuffer updates, we reduce CPU usage and improve frame rates.
📊 Impact:
🔬 Measurement:
Verified functional correctness with
./gradlew :app:testDebugUnitTest --tests "com.excp.podroid.x11.*". Arithmetic optimizations were verified by inspection andgrepto confirm the removal of/and%from decoding loops.PR created automatically by Jules for task 13173654984957449692 started by @kimocoder