From 23d78a90d4cee0d260f33fb989168b9c7ae15184 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 18:47:00 +0000 Subject: [PATCH] perf(drw): replace XSync with XFlush in drw_map for non-blocking drawing Using XSync forces a round-trip to the X server, blocking the client until the server processes the request. For frequent drawing operations like drw_map, this introduces unnecessary latency. XFlush ensures the request is sent without waiting for a response, significantly improving responsiveness during updates. --- .jules/bolt.md | 3 +++ drw.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 00000000..5d46ba9f --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2026-01-23 - XSync vs XFlush in drw_map +**Learning:** In X11 window managers, using XSync in frequent drawing paths (like drw_map) causes blocking round-trips to the X server, significantly degrading performance. +**Action:** Use XFlush for drawing operations where synchronous confirmation is not required. diff --git a/drw.c b/drw.c index 7e99a386..66e008bf 100644 --- a/drw.c +++ b/drw.c @@ -494,7 +494,9 @@ 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 is used here instead of XSync to avoid blocking round-trips + * during frequent drawing operations. */ + XFlush(drw->dpy); } unsigned int drw_fontset_getwidth(Drw *drw, const char *text) {