x11: cache X11 atoms
authorRan Benita <ran@unusedvar.com>
Wed, 18 Nov 2020 22:28:37 +0000 (00:28 +0200)
committerRan Benita <ran@unusedvar.com>
Fri, 20 Nov 2020 11:04:21 +0000 (13:04 +0200)
commit1bd3b3c7cb52ae77667d45cb46e8b5af3046a8d7
tree067bb54b2daf23dcef11c24aed3ac8b65f8c4d9c
parentf41e609bbea8447fc82849a1a6ea0d116189f2f8
x11: cache X11 atoms

On every keymap notify event, the keymap should be refreshed, which
fetches the required X11 atoms. A big keymap might have a few hundred of
atoms.

A profile by a user has shown this *might* be slow when some intensive
amount of keymap activity is occurring. It might also be slow on a
remote X server.

While I'm not really sure this is the actual bottleneck, caching the
atoms is easy enough and only needs a couple kb of memory, so do that.

On the added bench-x11:

Before: retrieved 2500 keymaps from X in 11.233237s
After : retrieved 2500 keymaps from X in 1.592339s

Signed-off-by: Ran Benita <ran@unusedvar.com>
bench/x11.c [new file with mode: 0644]
meson.build
src/context.c
src/context.h
src/x11/util.c