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
Many getpid calls wasting CPU resources #5447
Comments
This is actually mostly down to one single assert. parser_t &parser_t::principal_parser() {
ASSERT_IS_NOT_FORKED_CHILD();
ASSERT_IS_MAIN_THREAD();
return s_principal_parser;
} It turns out this is hammered. Since it's just an assert, let's just remove it. That reduces my tally from 789 to 15, for a simple Quite surprisingly, it also seems to reduce the time taken for for i in (seq 10000); test 1 = 1; end by ~40%. |
Fixed by a7998c4. |
This is the more correct fix for #5447, as regardless of which process in the job (be it the first or the last) finished first, once we have waited on a process without ~WNOHANG we don't do that for any subsequent processes in the job. It is also a waste to call into the kernel to wait for a process we already know is completed!
Yes it's safe. The assertion is just to catch mistakes, it has no functional purpose. |
Has anybody compared performance in fish with and without |
@floam: Our assert isn't from assert.h, and it does not respect NDEBUG. See src/common.h. |
Picked into 3.0.1 as 171ae99 |
With both fish 3.0 and fish 2.7.1 since Glibc disabled the getpid cache, fish shell seems to call getpid a lot. I have observed this issue on Arch linux for a couple of months. Using, the default configuration a
strace -c fish
followed by a C-d to terminate the shell gives,The effect is worse with my current personal configuration, it has even more calls seen below is the top strace results run on fish 3.0.
I think many of these calls are probably unnecessary. Further, the shell continues to call a large amount of getpid calls during use as well not just startup.
The text was updated successfully, but these errors were encountered: