logo

Show HN: A wc rewrite in Rust that makes it over 100 times faster

Posted by CallMeAlphabet |2 hours ago |2 comments

ventana 2 hours ago[1 more]

At the first glance, the 100x difference is surprising. My first thought was that the Rust code [1] uses AVX instructions, which would've explained the difference if the regular wc was a naive C code counting characters in a loop; but from what I see, at least the regular coreutils wc [2] uses AVX too, so the reasons of the 100x difference are not immediately obvious to me. Have you got any good explanation why? I don't believe it's Rust vs C, it might be some optimization that does not exist in the coreutils C code?

[1]: https://github.com/CallMeAlphabet/fastwc/blob/main/src/main....

[2]: https://github.com/coreutils/coreutils/blob/master/src/wc.c