Conversation
Optimized the ZRLE decoder by merging ZInput logic, increasing buffer sizes to 16KB to minimize JNI overhead, and refactoring RLE decoding loops to use incremental counters and bulk memory operations (Arrays.fill). - Merge ZInput into ZrleDecoder to avoid per-rectangle allocation. - Increase buffers to 16KB for better zlib decompression efficiency. - Replace division/modulo with incremental counters in RLE loops. - Use Arrays.fill for contiguous pixel runs. - Implement fast-path for 3-byte CPIXEL reads. 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. |
There was a problem hiding this comment.
Pull request overview
This PR optimizes the ZRLE (RFB encoding 16) decode hot path by reducing inflater JNI overhead, removing per-rectangle helper allocations, and speeding up tile filling (especially for RLE/solid runs) to improve UI rendering performance.
Changes:
- Increased zlib input/output buffers to 16KB and moved decompression state into
ZrleDecoder(removing the per-rectZInputwrapper/allocation). - Optimized solid and RLE tile decoding by using incremental row/col counters and
Arrays.fillfor contiguous pixel spans (avoids per-pixel div/mod). - Added a
.jules/bolt.mdnote capturing the performance learnings and guidance.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/src/main/java/com/excp/podroid/x11/ZrleDecoder.kt | Reworks decompression buffering and optimizes tile decode loops (solid/RLE/cpixel reads) for performance and lower GC pressure. |
| .jules/bolt.md | Adds internal documentation capturing the performance rationale and recommended patterns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Decompressed output buffer (internal to ZInput logic). | ||
| private var zBuf = ByteArray(BUFFER_SIZE) |
💡 What: Optimized the ZRLE (Remote Framebuffer encoding 16) decoder in
ZrleDecoder.kt.🎯 Why: The previous implementation suffered from several performance bottlenecks:
Inflaterdue to small buffer sizes.ZInput.📊 Impact:
Arrays.filland elimination of division/modulo significantly speed up pixel filling for solid areas and RLE runs.readCpixelfast-path reduces branching and call stack depth.ZInputobject allocation for every rectangle.🔬 Measurement: Verified correctly using
./gradlew :app:testDebugUnitTest --tests "com.excp.podroid.x11.ZrleDecoderTest". All 6 functional and safety tests passed.PR created automatically by Jules for task 3852142178869252272 started by @kimocoder