-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow first start/initialization #340
Comments
The startup time depends on the device and also on the operating system. It is typically about 100-400 msec in a Linux environment. Based on the reports I have received so far, the performance in macOS seems to be slower than Linux, but I haven't actually tested it in macOS as I don't have it.
This is expected. As you suspected, the startup for the first time is slower due to caching, specifically for the caching of the terminal sequences and keymaps. After the first-time initialization, it shouldn't take so much time, but it is still slower than plain Bash. If you request zero cost from ble.sh, it's impossible.
There are two phases in the initialization. The first one is the loading phase ( If you would like to see the initialization time measurements for the first phase, you can change the following line of the source file diff --git a/ble.pp b/ble.pp
index 00e85a32..b05b8d6d 100644
--- a/ble.pp
+++ b/ble.pp
@@ -1,7 +1,7 @@
#!/bin/bash
#%$> out/ble.sh
#%[release = 0]
-#%[measure_load_time = 0]
+#%[measure_load_time = 1]
#%[debug_keylogger = 1]
#%[leakvar = ""]
#%#---------------------------------------------------------------------------- If you would like to profile the second phase, you can modify # at the end of bashrc
if [[ ${BLE_VERSION-} ]]; then
ble/debug/profiler/start a
ble-attach
ble/debug/profiler/stop
fi Then, two files $ sort -rk 6 a.func.txt | head -20 It should be noted that the time measurements and profiler make the startup even slower because the processing of time measurements and profiling also takes time. |
To measure the time of the first-time startup, you can clear the cache before loading ble.sh using the following command $ bash /path/to/ble.sh --clear-cache |
Perfect, thank you. Here are my results. Loading phaseWithout cache.
With cache.
In this phase it takes ~0.15 sec longer to load while building the cache. Attaching phaseWithout cache.
With cache.
In this phase many parts take much longer without the cache. (You may notice Not sure if there is anything actionable here for me. Maybe something will stand out to you. |
What is your request: to speed up the startup when there is an existing cache, or to speed up the cache creation? If it is the latter, I will not try to improve the performance of the cache creation because the cached part is what is hard to improve the performance. If the performance could have been improved, that part wouldn't have been cached but would have been processed directly. |
I have added the sums for the binding part. In total my startup times are roughly ~1800ms without cache and ~420ms with cache. This is on an M1 macbook pro which I would think should be competitive with the best results you have seen.
Is the 100-400 ms time you cite here for cached start? Either way it seems like these results are not really in line with expectations. I guess I am wondering if you notice any functions taking particularly long here that might be running especially poorly on mac for whatever reason. |
Sorry for the delayed reply.
I think this is the normal range of the delay, although I think 420ms is a bit slower than my experience in Linux but the order is the same.
Yes.
I don't see any significant difference in a particular function. However, the prompt construction and layout seem to take a longer time as a whole with your setup. One possibility is that your starship prompt produces relatively long prompt strings. |
ble version: 0.4.0-devel4+f16c0d8
Bash version: 5.2.15(1)-release (aarch64-apple-darwin22.1.0)
My login shell is zsh but I've been playing with BLE by starting bash from zsh. On first starting bash with BLE it takes quite a long time to load the first time, like over a second. Then if I exit bash and start again it is quicker (due to caching?) but still noticeably slower than I would expect. When I start bash without my user config (without BLE) it is instantaneous.
I looked around and didn't find any documentation or discussion about initialization performance so I'm not sure if this is expected behavior. I'm also not exactly sure how to benchmark the startup time. Any ideas for benchmarking and improving the slow startup time? Might look at https://github.com/romkatv/zsh-bench for inspiration.
The text was updated successfully, but these errors were encountered: