Slow startup
On NixOS 24.11 / Hyprland it takes anywhere between 1-2s before the selection UI is displayed.
strace shows a lot of openat for various themes, cursors, etc. Most of these seem rather unnecessary. The moment UI is displayed is marked in the trace. In this case it's about 1.8s.
Hmm, I wonder if this because in Nix it's using different files than other parts of the system, so those files aren't in the file cache yet. If you run it twice, is the second time faster?
Unfortunately, the way wayland works, it is necessary to open various files for example to get the data for the cursor bitmap, the keyboard mapping, etc.
For cursors specifically, there is a relatively new protocol in staging that could be used to avoid loading a file: https://wayland.app/protocols/cursor-shape-v1
If you run it twice, is the second time faster?
No, I got more or less the same results on consecutive runs.
strace slows things down so in reality, it is ~1s usually (~500-600ms just now, running slurp without any parameters) but that's still rather slow I think.
Hmm, I wonder if this because in Nix it's using different files than other parts of the system,
I wonder why there are so many ENOENTs for /nix/store files. That doesn't make any sense. But there aren't that many of those. What surprises me more is that it actually opens every single cursor file it finds, twice in at least some cases. That feels like a nuclear overkill just to get the crosshair shape cursor. There are over 1400 openat events. The syscalls alone take over 160ms according to strace -c. The bulk is IO related to those I suppose.
it is necessary to open various files for example to get the data for the cursor bitmap,
As I understand, this is only to get the current theme's crosshair shape. Personally, I'd be ok with a generic crosshair shape or an option to specify path to the cursor bitmap directly to avoid the delay. Would that be feasible?
It looks like slurp just delegates to the wayland library to load the theme and choose a cursor: https://github.com/emersion/slurp/blob/7a91fe68a67d37b98a904f41f535549a223efccb/main.c#L850
And I think it only does that if the compositor doesn't support the cursor shape protocol
Hm. I'm on Hyprland 0.45.2 which should support the cursor-shape protocol.