Make startup subshell async to speed it up - #5148
Conversation
|
Oh man, after all the tons of work that went into fixing subshell initialization races, this sounds maximally dangerous, and it comes with no tests. I wish @egmontkob could look into this, because he did the earlier fixing, but I guess he wouldn't have time and interest. And I don't have time at the moment, unfortunately. |
Yeah, I was kind of wondering if my "little change" would be dangerous for everything else. I can think of some tests & try to fix the failing builds but if this step is so relevant for the whole project I understand this might wait...indefinitely...anyhow thank you! Edit: builds are failing because I forgot to commit the test folder (sorry), I'll double check them and push them in the next days. |
Signed-off-by: Giovanni Alzetta <giovannialzetta@hotmail.it>
Signed-off-by: Giovanni Alzetta <giovannialzetta@hotmail.it>
9c64721 to
89b0e9c
Compare
|
I force pushed because I also did a rebase. I reviewed the tests I had written and now I pushed them. I tried to copy the style from the other tests. |
|
so much "fun" ... please squash the commits, and write a proper commit message. elaborate on how the event dependencies change, which potential problems you have considered, etc. Questions raised in the long thread's on egmont's PRs may also be relevant targets. some "answers" may be best provided by test cases. |
Proposed changes
Checklist
init_subshell()currently forks the user's shell and then blocks synchronously until it finishes sourcing its rc file. On my mac this is very slow and it contributes to #4625 and #4781.This PR skips that wait:
init_subshell()still forks the shell at start up but does so asyncronously.It registers the CWD-report pipe with mc's existing event-loop machinery used for
background-job progress and the steady-state prompt updates in
load_prompt(), making this a minor code change.The loading is protected: if the user tries to access the shell before the async loading is done they'll wait for it finish loading.
On My macOS I measured the change (I use oh-my-zsh and other init routines):
init_subshell()'s blocking window drops from ~850ms to ~10ms.git commit --amend -smake indent && make check)Notes
I am a long time mc user, but it has been a while since I contributed to an open source project like this: I made this change because the wait time is pushing me towards not using mc. Please let me know if there is anything I missed or I could do better. Thank you!