-
-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Optimize CLI commands performance #104
Comments
Motivation: 1. Small optimization. One less client-server hoop. #104 Before the commit (debug, idle) time aerospace list-workspaces --all real 0m0.041s user 0m0.002s sys 0m0.001s (debug, busy, 8 windows) alt-w = ['workspace W', 'exec-and-forget bash -c "time /Users/bobko/a/AeroSpace/LocalPackage/.build/debug/aerospace list-workspaces --all" 2> ~/log'] real 0m0.165s user 0m0.002s sys 0m0.001s After the commit (debug, idle) time aerospace list-workspaces --all real 0m0.024s user 0m0.002s sys 0m0.002s (debug, busy, 8 windows) alt-w = ['workspace W', 'exec-and-forget bash -c "time /Users/bobko/a/AeroSpace/LocalPackage/.build/debug/aerospace list-workspaces --all" 2> ~/log'] real 0m0.145s user 0m0.004s sys 0m0.004s 2. Now if server and client have different versions, but understand each other, the error is not reported
Motivation: 1. Small optimization. One less client-server hoop. nikitabobko#104 Before the commit (debug, idle) time aerospace list-workspaces --all real 0m0.041s user 0m0.002s sys 0m0.001s (debug, busy, 8 windows) alt-w = ['workspace W', 'exec-and-forget bash -c "time /Users/bobko/a/AeroSpace/LocalPackage/.build/debug/aerospace list-workspaces --all" 2> ~/log'] real 0m0.165s user 0m0.002s sys 0m0.001s After the commit (debug, idle) time aerospace list-workspaces --all real 0m0.024s user 0m0.002s sys 0m0.002s (debug, busy, 8 windows) alt-w = ['workspace W', 'exec-and-forget bash -c "time /Users/bobko/a/AeroSpace/LocalPackage/.build/debug/aerospace list-workspaces --all" 2> ~/log'] real 0m0.145s user 0m0.004s sys 0m0.004s 2. Now if server and client have different versions, but understand each other, the error is not reported
Note this gets extremely bad when CPU usage is saturated (e.g. when compiling a large Rust project), Aerospace becomes completely unresponsive. The 'fix' I have in place for now is limiting the number of CPUs available to rustc. |
I am using numerous aerospace CLI commands for my daily workflows (e.g., cycling through windows of active applications, focusing particular windows, etc.). The ~100 ms CLI became somewhat annoying to me since I started to feel the delay when I have ~300 ms in my scripts. For this purpose, I experimented with some hacky cache:
From there on, my scripts simply use I was wondering if some internal caching mechanism like that would be useful in general. For example, the focused window will not change until the "on-focus-changed" event is triggered. However, if I run it 3 times in a row, each run takes approximately 100 milliseconds. |
Motivation: 1. Small optimization. One less client-server hoop. nikitabobko/AeroSpace#104 Before the commit (debug, idle) time aerospace list-workspaces --all real 0m0.041s user 0m0.002s sys 0m0.001s (debug, busy, 8 windows) alt-w = ['workspace W', 'exec-and-forget bash -c "time /Users/bobko/a/AeroSpace/LocalPackage/.build/debug/aerospace list-workspaces --all" 2> ~/log'] real 0m0.165s user 0m0.002s sys 0m0.001s After the commit (debug, idle) time aerospace list-workspaces --all real 0m0.024s user 0m0.002s sys 0m0.002s (debug, busy, 8 windows) alt-w = ['workspace W', 'exec-and-forget bash -c "time /Users/bobko/a/AeroSpace/LocalPackage/.build/debug/aerospace list-workspaces --all" 2> ~/log'] real 0m0.145s user 0m0.004s sys 0m0.004s 2. Now if server and client have different versions, but understand each other, the error is not reported
aerospace list-workspaces
is slow. Well,aerospace list-workspaces
is ~100ms which by itself is fine.(1) But 100ms is the result when AeroSpace is idle. Currently AeroSpace performs all operations in one thread. Considering that Ax calls are blocking, 100ms becomes worse when a lot of Ax calls are performed.
It can be tested with
alt-w = ['workspace W', 'exec-and-forget bash -c "time ~/.bin/aerospace list-workspaces" 2> ~/log']
. I have 9 windows opened, and I get 300ms in~/log
. 300ms is not that nice(2) The problem becomes worse when users need to call
aerospace list-workspaces
several times (E.g. to get all workspaces and focused workspaces).list-workspaces
is designed to be called several times. Maybe the design could be reconsidered, or--json
flag could be provided. With JSON format, AeroSpace could dump out all the info it knows about workspaces in a structured way.Reported at: #81
The text was updated successfully, but these errors were encountered: