-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Description
Describe the bug
Wrapper scripts for plasma apps such as krunner or plasma-emojier are slow. For example, executing just the wrapper for plasma-emojier takes 100ms on my fast machine.
The reason for slowness is that the wrapper itself repeatedly adds various paths:
$ rg -F "QT_PLUGIN_PATH='" $(which plasma-emojier) | wc -l
44This leads to quadratic behavior. Profiling with perf shows that the bulk of the time is spend in string manipulation routines.
The relevant logic is here:
| makeWrapper "$original" "$wrapper" "${qtWrapperArgs[@]}" "$@" |
Essentially, we are calling
wrapProgram program \
--prefix QT_PLUGIN_PATH ...
--prefix QT_PLUGIN_PATH ...
--prefix QT_PLUGIN_PATH ...and makeWrapper then faithfully translates each --prefix, instead of pre-computing thee concatenation.
Steps To Reproduce
# Strip the `exec` line
$ <$(which plasma-emojier) head -n -1 > wrapper.sh && chmod a+x ./wrapper.sh
# Time the execution of the wrapper itself
$ time ./wrapper.sh
real 0m0.117s 😱
user 0m0.115s
sys 0m0.002sExpected behavior
Wrapper itself shouldn't take more than a handful of milliseconds. It seems achievable if I manually replace incremental quadratic addition to environmental variables with setting them once.
Not sure what's the best fix here, some options I see are:
- fix
wrap-qt-apps-hookto pre-concatenate variables and pass just a single--prefixargument per variable towrapProgram - make
wrapProgramitself smarter and teach it to collate identical prefixes - fix
wrap-qt-apps-hookto use--setrather then--prefix
As I don't know bash, I don't plan on working on the fix myself
Notify maintainers
cc @ttuegel
Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.
[matklad@Ishmael:~/tmp]$ nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
- host os: `Linux 6.2.10, NixOS, 23.05 (Stoat), 23.05.20230411.3fb8eed`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.13.3`
- channels(matklad): `""`
- nixpkgs: `/nix/store/k9vs66va04886gl91m6lpcwaymqiihqx-9lkm36ac7hfl7f9h2z9dj00mdh30mjhi-source`