Repository navigation
perf(recording): reuse one X11 connection and unchanged cursor PNGs - #2622
Open
celeroncoder wants to merge 2 commits into
Open
celeroncoder wants to merge 2 commits into
celeroncoder wants to merge 2 commits into
Conversation
Contributor
|
@celeroncoder 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.
Stacked on #2621. The first commit is #2621. Review 5c655ea only, or wait for #2621 to merge.
On X11 the cursor recorder calls
get_x11_cursor_data()every tick (about 60/s). Each call:x11rb::connect(socket, auth, setup)xfixes_query_versionGetCursorImageChange (Linux only)
X11CursorSource(crates/recording/src/cursor.rs:857) owns the connection and does the XFixes handshake once. It lives in athread_local!inside the Linuxget_cursor_data(), so each recorder thread has its own and closes it when the thread exits.Nonelikemaindid. No retry loop.GetCursorImageis still requested every tick, so a shape change shows up on the next tick as before. PNG bytes are identical tomain, so cursor ids (SHA-256 of the PNG), savedcursor_N.pngfiles and hotspots don't change.cursor::x11_cursor_teststhat need no X server:cached_cursor_pngs_match_a_fresh_encodecovers the same image, changed pixels, swapped width/height and switching back. It fails if either the dimension or the pixel check is dropped from the cache key.cursor_pixels_are_encoded_as_rgbacursor_with_mismatched_pixel_count_is_skippedResults (Linux X11)
main@ 83237e9connect()per tick, moving pointerThe real
spawn_cursor_recorderran for 10 s from release builds against Xvfb 1920x1080 on a shared 2 vCPU aarch64 VM. CPU is the recorder's user+sys fromgetrusage, median of 5 interleaved runs with the range in brackets. Connection counts come from one strace run.Output equivalence
main'sget_x11_cursor_data(copied verbatim) across 10 root-cursor changes over 6 shapes, including repeats and switching back. Every PNG and hotspot was byte-identical. The cache re-encoded on every shape change and reused the PNG only when the image was unchanged.main, perf(recording): take the cursor position from the recorder's mouse sample #2621 and this branch while the root cursor cycled through 6 shapes every 400 ms. All three registered the same 6 cursors with identical PNG-hash keys, hotspots and saved files. The move timeline switched cursor id 25 times on each, so no stale cursor was served.KillClient, 3 times): each next call reconnected within the call (about 0.35 ms) and returned the real cursor. With an unreachableDISPLAYthe call returnedNoneonce, then reconnected afterDISPLAYwas restored.Scope and overlap
mainskips the recorder when it prefers the portal cursor (prefers_wayland_portal_cursor). If feat(linux): enable Wayland window/display recording with PipeWire cursor metadata and evdev clicks #2420 lands and the recorder runs under XWayland, this source works the same way there.git merge-treeshows no conflicts beyond the ones perf(cursor): stop hashing an unchanged cursor image every tick #2466 already has withmain.cursor.rshunks apply cleanly on top of this.How this was made
This PR is agent-generated.
space-bunny-free(OpenCode) found this during an audit of the repo and wrote the first patch.main, added the tests and took the measurements above.🤖 Generated with Claude Code


Confidence Score: 5/5
The reviewed commit appears safe to merge.Summary
Reviewed commit
5c655eabas requested. The earlier coordinate changes belong to the preceding stacked PR and are excluded.No actionable issues found. This review used code inspection; tests were not run.
Reviews (1) · Last reviewed commit: "perf(recording): keep one X connection f..." · Reviewed by Greptile