From 349ed806001ace5841534642200258b50e98a91d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 20 Jan 2026 18:40:18 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Replace=20blocking=20XSync?= =?UTF-8?q?=20with=20XFlush=20in=20hot=20paths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .jules/bolt.md | 3 +++ client.c | 2 +- drw.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 00000000..b8f2743b --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2026-01-20 - XSync vs XFlush in Event-Driven Drawing +**Learning:** `XSync` is a blocking round-trip to the X server, while `XFlush` is asynchronous. In `instantwm`, `XSync` was used in `drw_map` (called on every bar redraw) and `resizeclient` (called on every window resize), causing significant performance degradation due to unnecessary waiting for server confirmation. +**Action:** Replace `XSync` with `XFlush` in high-frequency drawing/window management paths when immediate confirmation is not strictly required for logic correctness. diff --git a/client.c b/client.c index 13f1e27f..c03e6b4b 100644 --- a/client.c +++ b/client.c @@ -279,7 +279,7 @@ void resizeclient(Client *c, int x, int y, int w, int h) { XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); configure(c); - XSync(dpy, False); + XFlush(dpy); } void updatetitle(Client *c) { diff --git a/drw.c b/drw.c index 7e99a386..e3f9501b 100644 --- a/drw.c +++ b/drw.c @@ -494,7 +494,7 @@ void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, } XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y); - XSync(drw->dpy, False); + XFlush(drw->dpy); } unsigned int drw_fontset_getwidth(Drw *drw, const char *text) {