From bae1f4b354500862584b26748398e30b36a28d33 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 5 Mar 2021 14:16:52 +0100 Subject: [PATCH 1/2] Prefetch some information through xcb This commit makes libxcb prefetch some information that will be needed later anyway. This avoids some round-trips to the X11 server since the information is already present when needed. Signed-off-by: Uli Schlachter --- src/main.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 54b38f44..3d262c94 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #ifdef I3_ASAN_ENABLED #include @@ -573,6 +575,14 @@ int main(int argc, char *argv[]) { root_screen = xcb_aux_get_screen(conn, conn_screen); root = root_screen->root; + /* Prefetch X11 extensions that we are interested in. */ + xcb_prefetch_extension_data(conn, &xcb_xkb_id); + xcb_prefetch_extension_data(conn, &xcb_xinerama_id); + xcb_prefetch_extension_data(conn, &xcb_randr_id); + xcb_prefetch_extension_data(conn, &xcb_shape_id); + /* BIG-REQUESTS is used by libxcb internally. */ + xcb_prefetch_extension_data(conn, &xcb_big_requests_id); + /* Place requests for the atoms we need as soon as possible */ #define xmacro(atom) \ xcb_intern_atom_cookie_t atom##_cookie = xcb_intern_atom(conn, 0, strlen(#atom), #atom); @@ -602,6 +612,8 @@ int main(int argc, char *argv[]) { visual_type = get_visualtype(root_screen); } + xcb_prefetch_maximum_request_length(conn); + init_dpi(); DLOG("root_depth = %d, visual_id = 0x%08x.\n", root_depth, visual_type->visual_id); @@ -666,9 +678,6 @@ int main(int argc, char *argv[]) { xcursor_set_root_cursor(XCURSOR_CURSOR_POINTER); const xcb_query_extension_reply_t *extreply; - xcb_prefetch_extension_data(conn, &xcb_xkb_id); - xcb_prefetch_extension_data(conn, &xcb_shape_id); - extreply = xcb_get_extension_data(conn, &xcb_xkb_id); xkb_supported = extreply->present; if (!extreply->present) { From db5a7dc22a136c7077a3646abefcdf7a81afe2ad Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 6 Mar 2021 18:43:46 +0100 Subject: [PATCH 2/2] Only prefetch xinerama if it is likely needed Signed-off-by: Uli Schlachter --- src/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 3d262c94..5590bf4b 100644 --- a/src/main.c +++ b/src/main.c @@ -577,11 +577,14 @@ int main(int argc, char *argv[]) { /* Prefetch X11 extensions that we are interested in. */ xcb_prefetch_extension_data(conn, &xcb_xkb_id); - xcb_prefetch_extension_data(conn, &xcb_xinerama_id); - xcb_prefetch_extension_data(conn, &xcb_randr_id); xcb_prefetch_extension_data(conn, &xcb_shape_id); /* BIG-REQUESTS is used by libxcb internally. */ xcb_prefetch_extension_data(conn, &xcb_big_requests_id); + if (force_xinerama) { + xcb_prefetch_extension_data(conn, &xcb_xinerama_id); + } else { + xcb_prefetch_extension_data(conn, &xcb_randr_id); + } /* Place requests for the atoms we need as soon as possible */ #define xmacro(atom) \