Skip to content

Conversation

@paperbenni
Copy link
Member

@paperbenni paperbenni commented Feb 4, 2026

πŸ’‘ What: Replaced XSync(drw->dpy, False) with XFlush(drw->dpy) in drw_map (drw.c).

🎯 Why: XSync forces the client to wait for the X server to process the request, creating a blocking round-trip. In high-frequency paths like drawbar (which calls drw_map on every focus change, clock tick, or tag switch), this adds unnecessary latency and CPU overhead.

πŸ“Š Impact: Reduces latency for every bar redraw. The UI will feel snappier, especially under load or with higher network latency (if remote).

πŸ”¬ Measurement: Verified build with make clean && make. No visual regressions expected as X11 guarantees request ordering.


PR created automatically by Jules for task 14763089325153825185 started by @paperbenni

Summary by Sourcery

Optimize X11 bar drawing by replacing a blocking XSync call with a non-blocking XFlush in drw_map to reduce redraw latency and CPU overhead.

Enhancements:

  • Improve drw_map rendering performance by avoiding a blocking XSync round-trip in favor of XFlush for bar updates.

Documentation:

  • Add a Jules bolt note documenting the choice of XFlush over XSync for frequent drawing operations.

Replacing XSync with XFlush in drw_map avoids unnecessary blocking round-trips to the X server during frequent drawing operations (like bar updates), significantly improving responsiveness.

Co-authored-by: paperbenni <15818888+paperbenni@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

πŸ‘‹ 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • πŸ” Trigger a full review
✨ Finishing touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bolt-drw-map-optimization-14763089325153825185

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 4, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Optimize X11 bar drawing by replacing a blocking XSync call with a non-blocking XFlush in drw_map, and document the learning in a new Jules bolt note.

Sequence diagram for optimized drw_map XFlush-based drawing

sequenceDiagram
    actor User
    participant WM as WindowManager
    participant Drw as Drw
    participant X11 as XServer

    User->>WM: Trigger bar update (focus change, clock tick, tag switch)
    WM->>Drw: drawbar
    Drw->>Drw: prepare drawable buffer
    Drw->>X11: XCopyArea(drw_drawable, win, gc, x, y, w, h, x, y)
    Drw->>X11: XFlush(dpy)
    X11-->>X11: Process requests asynchronously
    X11-->>User: Updated bar appears when processed
Loading

File-Level Changes

Change Details Files
Reduce blocking round-trips to the X server in the drw_map drawing path.
  • Replace XSync with XFlush after XCopyArea in drw_map to avoid waiting for the X server
  • Add an inline comment explaining why XFlush is sufficient and preferable in this path
drw.c
Capture the XSync vs XFlush performance learning in project documentation.
  • Add a new .jules/bolt.md note describing why XSync is problematic for frequent drawing operations and recommending XFlush instead
  • Deduplicate/clarify the note content to emphasize the bar update/drw_map use case
.jules/bolt.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In .jules/bolt.md the "XSync vs XFlush" section is duplicated and the first entry is missing backticks/formatting around XSync and drw_map, so it would be good to consolidate this into a single correctly formatted section.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `.jules/bolt.md` the "XSync vs XFlush" section is duplicated and the first entry is missing backticks/formatting around `XSync` and `drw_map`, so it would be good to consolidate this into a single correctly formatted section.

## Individual Comments

### Comment 1
<location> `.jules/bolt.md:2-3` </location>
<code_context>
+## 2026-02-04 - XSync vs XFlush in Drawing
+**Learning:**  forces a blocking round-trip to the X server, which is catastrophic for frequent drawing operations like bar updates ().
+**Action:** Use  for drawing operations where the client doesn't need to wait for the server's response.
+## 2026-02-04 - XSync vs XFlush in Drawing
+**Learning:** `XSync` forces a blocking round-trip to the X server, which is catastrophic for frequent drawing operations like bar updates (`drw_map`).
</code_context>

<issue_to_address>
**issue (typo):** The first "Learning" and "Action" lines appear incomplete and missing function names.

In the first pair of lines, the text after "**Learning:**" is missing, and "bar updates ()" has empty parentheses. The "**Action:** Use  for drawing..." line also lacks the function name. Since the second pair of lines already correctly mentions `XSync`, `XFlush`, and `drw_map`, please either complete these first two lines to match the intended wording or remove them if they were an earlier draft.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click πŸ‘ or πŸ‘Ž on each comment and I'll use the feedback to improve your reviews.

Comment on lines +2 to +3
**Learning:** forces a blocking round-trip to the X server, which is catastrophic for frequent drawing operations like bar updates ().
**Action:** Use for drawing operations where the client doesn't need to wait for the server's response.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (typo): The first "Learning" and "Action" lines appear incomplete and missing function names.

In the first pair of lines, the text after "Learning:" is missing, and "bar updates ()" has empty parentheses. The "Action: Use for drawing..." line also lacks the function name. Since the second pair of lines already correctly mentions XSync, XFlush, and drw_map, please either complete these first two lines to match the intended wording or remove them if they were an earlier draft.

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.

1 participant