4 ms·
> So what am I missing here? The Haskell program is multi-threaded (I don't know about wc's official implementation, but I assume it is as well), while the D p
by EvenThisAcronym 7y ago
> So what am I missing here?
The Haskell program is multi-threaded (I don't know about wc's official implementation, but I assume it is as well), while the D program is single-threaded.
- wtetzner 7y agoSo, that sounds like it's CPU bound then...
- unwind 7y agoGNU coreutils' wc (which is the reference) does not seem to be using threads, no. At least not at all obviously. No obvious header included and no mention of threads. I only checked the code [1] very quickly, though. [1] https://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/wc.c;h=d18eaee6c33e1a67b65f1e62bb427e8777bc0aed;hb=HEAD https://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;...
- greggyb 7y agoI saw that. If adding threads makes a program faster, that implies that more CPU can make it go faster. If the filesystem is already streaming bytes to the program as fast as it can, adding threads just means that you have more threads waiting for bytes. If adding threads increases the speed, this implies that the program is both CPU-bound and that it has opportunities for parallelism.