Skip to content

Conversation

@paperbenni
Copy link
Member

@paperbenni paperbenni commented Feb 3, 2026

Bolt Optimization

What:
Replaced XSync with XFlush in drw_map (drawing function).

Why:
XSync blocks the client (window manager) until the X server processes the request. In a drawing loop (used by the status bar and other UI elements), this forces a round-trip for every map operation, significantly reducing performance and responsiveness. XFlush sends the request asynchronously, allowing the WM to continue processing other events.

Impact:

  • Measurably lower latency during redraws.
  • Reduced CPU usage due to fewer blocking calls.
  • Smoother UI updates.

Verification:

  • make clean && make passes.
  • Code review confirmed XFlush is safe for this context (ordering is guaranteed by X11 protocol).

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

Summary by Sourcery

Optimize X11 drawing synchronization to reduce blocking in the drawing path and record the change in internal documentation.

Enhancements:

  • Replace blocking XSync with non-blocking XFlush in drw_map to improve drawing performance and responsiveness.

Documentation:

  • Add an internal Bolt note documenting why XSync is harmful in hot drawing loops and the decision to use XFlush instead.

Replaces the blocking `XSync(drw->dpy, False)` call with `XFlush(drw->dpy)` in `drw_map`.
`XSync` forces a round-trip to the X server, causing the window manager to block until the server processes the drawing request. This is unnecessary for basic drawing operations and degrades responsiveness. `XFlush` ensures the request is sent without waiting for a reply.

Impact:
- Reduces latency during UI updates (bar drawing, etc.).
- Eliminates unnecessary context switches and blocking I/O.

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 3, 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-optimize-drw-map-xflush-12737494073342133402

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.


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 3, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Replaces a blocking XSync call with a non-blocking XFlush in the drw_map drawing routine to improve performance, and adds a Jules bolt note documenting the X11 synchronization learning and action.

Sequence diagram for drw_map interaction with X server using XFlush instead of XSync

sequenceDiagram
    participant WM as WindowManager
    participant Drw as Drw_drw_map
    participant X as XServer

    WM->>Drw: drw_map(drw, win, x, y, w, h)
    Drw->>X: XCopyArea(drw->drawable -> win)
    alt Previous_behavior_with_XSync
        Drw->>X: XSync(dpy, False)
        X-->>Drw: Process all pending requests
        Drw-->>WM: Return after server completes
    else Updated_behavior_with_XFlush
        Drw->>X: XFlush(dpy)
        Note over Drw,X: Requests sent asynchronously, no round-trip wait
        Drw-->>WM: Return immediately, continue event processing
    end
Loading

Flow diagram for updated drw_map drawing routine

flowchart TD
    A[Start drw_map] --> B[Validate Drw pointer and dimensions]
    B --> C[Call XCopyArea to copy from drawable to window]
    C --> D[Call XFlush on display]
    D --> E[Exit drw_map without waiting for X server]
    E --> F[WM continues processing other events]
Loading

File-Level Changes

Change Details Files
Optimize the drw_map drawing routine by avoiding blocking X11 synchronization.
  • Replace XSync with XFlush after XCopyArea to prevent client blocking on every draw call
  • Add an inline comment explaining why XFlush is sufficient and XSync is detrimental to performance in this context
drw.c
Document the XSync vs XFlush performance learning for future work.
  • Create a new .jules/bolt.md note capturing the insight about XSync causing blocking round-trips in drawing loops
  • Record the recommended action to use XFlush in drawing routines where strict synchronization is not required
.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 reviewed your changes and they look great!


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.

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