-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fish as the leader of fastest shell #2776
Comments
This benchmark is not really fair. Even on the relatively simple Pi-2, I expect the first run to be much slower then the rest, due to caching. |
@oranja, it's not the first run, I took many run (5) and get the best result. |
There's a few things to note here:
@pickfire: You've cleared your config.fish, so that's not included, but this is something to keep in mind. Though presumably if the end result is the same you don't care how much more work fish did to get there.
|
@pickfire: Okay, that log shows ( So it's actually interesting that mksh manages to be faster. On my system it's close enough to not matter either way (consistently mksh < fish < bash < zsh, but within 0.08s of each other - this is with extensive fish customization, a medium bashrc and a comparatively tiny zshrc). |
Ah, I didn't know there is Yeah, I figured it out, like you said @faho And one more thing, mkshrc by default is actually a bit huge which has 600+ lines (comments included). |
Not quite - look at the very first non-comment line:
I didn't actually have that because arch only puts it in /etc/skel. Though even after copying it to ~ it doesn't slow mksh down even one centisecond. That's rather impressive. Though of course size doesn't matter (.............) - this file has everything protected from aliasing by prepending "". And, as we saw earlier, the config file doesn't matter - it barely shows up in fish, even with my (comparatively) extensive customization. |
Woah, now to get the fastest shell title, I guess we really need to be faster than |
Universal variables are also relevant - it's easy to forget about those but they get loaded at startup too. |
@ridiculousfish My universal variable is no more than 25, I don't know if universal variables can be optimized. Well, of course it is better so. |
@pickfire If you don't mind, can you post the output of |
@pickfire: That's the short version. You'll want to add "-L" to the options you pass to set - for all we know, these CFLAGS or fish_user_abbreviations could be gigantic. They're probably not, as your times look about right, but something like (Also, there's some sort of token in there you might want to censor) @bucaran: fishtape is yours, right? Any reason why you're keeping all those variable copies around? |
@ridiculousfish I did another benchmark recently, now including
> fish -v
fish, version dedc7f6
> bash --version
GNU bash, version 4.3.42(1)-release (armv7l-unknown-linux-gnueabihf)
> echo $KSH_VERSION
@(#)MIRBSD KSH R52 2016/03/04
> pacman -Qs dash
local/dash 0.5.8-1
> time fish test.fish
0.68user 1.98system 0:09.15elapsed 29%CPU (0avgtext+0avgdata 4712maxresident)k
0inputs+0outputs (0major+109838minor)pagefaults 0swaps
> time bash test.sh
0.27user 1.12system 0:08.86elapsed 15%CPU (0avgtext+0avgdata 2840maxresident)k
0inputs+0outputs (0major+149668minor)pagefaults 0swaps
> time mksh test.sh
0.15user 0.80system 0:07.74elapsed 12%CPU (0avgtext+0avgdata 1900maxresident)k
0inputs+0outputs (0major+119260minor)pagefaults 0swaps
> time dash test.sh
0.10user 0.63system 0:06.98elapsed 10%CPU (0avgtext+0avgdata 1900maxresident)k
0inputs+0outputs (0major+100868minor)pagefaults 0swaps Even after I reset those fish configuration files, the result are even worse. |
Thanks pickfire. What exactly were the test scripts? What was the contents of the config files? What was the contents of the universal variable file? |
@ridiculousfish The test scripts are the same as the first post on this page. I had test it with all the lines in the config files removed, it is even slower. So I don't think it will be the case, https://github.com/pickfire/dotfiles/blob/alarm/home/config/fish/config.fish env.txt, it is a lot longer than before. My password is there too, everyone can help me to play the wargames and earn points for me. :) |
Removing stuff like I still can't reproduce this incidentally. |
Now I still don't get why the results is so different compared to last time. Even |
@pickfire: In a previous job working for Sequent Computer Systems one of my duties was dealing with performance issues reported by customers and doing benchmarking. Benchmarking is really, really, hard if you care about reproducibility of the results. Heck, just designing an appropriate benchmark that measures something meaningful is really hard. In the benchmarking community there are a huge number of micro-benchmarks that people (mostly companies who want to sell you something) use to show that product X is better than Y. They're mostly crap, or at least don't tell a consumer anything useful about how a system will behave under typical conditions. I modified the simple scripts in your original comment. I replaced the
Fish took almost three times longer, both elapsed and cpu user mode time, than bash on OS X, and more than 20x slower than ksh. Profiling showed that all the extra time was in running So there might be opportunities to improve the efficiency of the global config.fish file to reduce the cost of starting a new fish shell. Beyond that I don't know what you're trying to accomplish with this issue. Fish is never going to be a speed daemon due to its, by design, far larger dependency on external commands than other shells. |
@krader1961 Yup, I am going to benchmark it with your benchmarking script, I guess it is really important to keep the startup process fast as it not only waste our own time and instead it waste the time of the fishers. I will benchmark it without my configurations file and variables but for i in (seq 1000)
command true > /dev/null
end And will be runned by |
Just want to say thanks to all of your for your work on speeding up Fish. :) |
@krader1961 This test is even insane, fish is almost 10x slower compare to other shells. > cat test.fish
for i in (seq 1000)
command true > /dev/null
end
> cat test.sh
for i in $(seq 1000) ; do
true > /dev/null
done
> env XDG_CONFIG_HOME=/tmp/bogus XDG_DATA_HOME=/tmp/bogus time fish test.fish
0.67user 2.01system 0:07.28elapsed 36%CPU (0avgtext+0avgdata 4548maxresident)k
0inputs+0outputs (0major+83066minor)pagefaults 0swaps
> time bash test.sh
0.13user 0.04system 0:00.18elapsed 91%CPU (0avgtext+0avgdata 2820maxresident)k
0inputs+0outputs (0major+312minor)pagefaults 0swaps
> time mksh test.sh
0.04user 0.03system 0:00.08elapsed 85%CPU (0avgtext+0avgdata 1528maxresident)k
0inputs+0outputs (0major+202minor)pagefaults 0swaps
> time dash test.sh
0.03user 0.01system 0:00.05elapsed 74%CPU (0avgtext+0avgdata 1744maxresident)k
0inputs+0outputs (0major+164minor)pagefaults 0swaps The results are still the same as above, |
@pickfire: Why did you modify my script? Specifically, why did you change |
@krader1961 Fish is still the slowest if so. > env XDG_CONFIG_HOME=/tmp/bogus XDG_DATA_HOME=/tmp/bogus time fish test.fish
0.27user 0.02system 0:00.30elapsed 95%CPU (0avgtext+0avgdata 4664maxresident)k
0inputs+0outputs (0major+1096minor)pagefaults 0swaps |
Even after dropping redirection, fish is still the slowest too: > cat test.sh
for i in $(seq 1000) ; do
true
done
> cat test.fish
for i in (seq 1000)
true
end
> env XDG_CONFIG_HOME=/tmp/bogus XDG_DATA_HOME=/tmp/bogus time fish test.fish
0.21user 0.04system 0:00.26elapsed 94%CPU (0avgtext+0avgdata 4548maxresident)k
0inputs+0outputs (0major+1103minor)pagefaults 0swaps
> time bash test.sh
0.08user 0.00system 0:00.09elapsed 86%CPU (0avgtext+0avgdata 2824maxresident)k
0inputs+0outputs (0major+310minor)pagefaults 0swaps
> time mksh test.sh
0.02user 0.01system 0:00.03elapsed 76%CPU (0avgtext+0avgdata 1604maxresident)k
0inputs+0outputs (0major+203minor)pagefaults 0swaps
> time dash test.sh
0.01user 0.00system 0:00.02elapsed 43%CPU (0avgtext+0avgdata 1532maxresident)k
0inputs+0outputs (0major+165minor)pagefaults 0swaps |
Yes, fish is the slowest at running @pickfire it's dangerous to report benchmark results without also reporting what exactly we're measuring, and why the results are what they are. People can latch onto them and draw wrong conclusions. Basically we should be coming at it with the attitude "why does fish perform this way on this particular benchmark?", not "fish is the fastest/slowest and this proves it." I'd love to have you involved in crafting a real benchmarking suite, with benchmarks for specific areas: startup, external command execution, builtin / function execution, memory usage, and real-world scripts are some that come to mind. Having analogous scripts for other shells could be part of that too. If you'd like to propose some scripts to be part of the benchmark suite, I'll be glad to help review them. |
@ridiculousfish Nice job, I would love it. So should I start the benchmarking suite project in fish-shell? I guess it would be nice but I am actually not very sure about how to do a good benchmarking suite. |
@ridiculousfish: It's in |
Oh, so it is! Shows what I know! |
@pickfire Here's one way to go about it:
A fine way to start would be to make a |
There are two reasons to run benchmarks:
@pickfire has been focused on the latter. I would argue that the former, avoiding performance regressions, is more valuable at this point in fish's evolution. Our performance relative to comparable shells is "good enough" that there is little reason to invest in improving it. Especially when you consider all the other open issues that are bugs or enhancement requests that would greatly improve the usability of fish. Once we have a framework that helps us know when we're introducing changes that make performance worse we can worry about improving performance relative to our competition. |
So basically the building blocks are:
The The
Did I miss anything? |
Yes! but let's try to avoid recursive Makefiles, which are inevitably painful. One way is to structure it roughly like the
Then a top-level Makefile target:
etc. |
Ideally the driver would make some attempt to use something better than |
Full dtruss here: test.txt
I was a bit disappointed that the number of syscalls was so much higher than bash, that it performs so much slower. I had thought it was getting better! :( . It clearly lost this test... Until I ran it again, except with the option that shows the timings also so I could at least show off the tool... They actually performed nearly exactly the same when you compare the time on the clock. Goes to show that this stuff is HARD. Complicated systems and lots of data can sometimes be more harmful than helpful if are not very carful. |
@ridiculousfish Of course! No recursive Makefile. @floam Woah, that is some stuff that I don't know about. I would like to ask one question, what is actually the |
driver is the test harness, which I sketched as step 1 in this comment. |
Thanks, @pickfire, for making us think about this. However, I'm going to close it because it is too broad. Issue #2007 is an example that is sufficiently precise to allow us to know when the issue has been addressed. Making fish fast is a desirable goal but is so open ended as to be useless as an actionable issue. |
@ridiculousfish Benchmarks are taken on latest git fish with archlinuxarm on raspberry pi 2.
The text was updated successfully, but these errors were encountered: