68 karma · joined April 24, 2025
Would be interesting to try this out
What I'm really optimizing here is the functional equivalent of `sort | uniq -c | sort -n`
``` clang \ -g -ggdb -O3 \ -Wall -Wextra -Wpointer-arith \ -D_FORTIFY_SOURCE=2 -fPIE \ mmuniq.c \ -lm \ -Wl,-z,now -Wl,-z,relro \ -o mmuniq mmuniq.c:1:10: fatal error: 'byteswap.h' file not found 1 | #include <byteswap.h> | ^~~~~~~~~~~~ 1 error generated. make: ** [mmuniq] Error 1 ```
It may not be the most fair comparison because with these random fastqs I'm generating the vast majority of the input is unique so it could be overloading the cuckoo filter.
You don't really end up using these results in any specific analysis but it's super helpful for troubleshooting tools or edge-cases.
But you're right - it will be limited by RAM in a way the unix tools are not.
I did add a test with sort using a larger buffer size to the benchmarks as well.
You're right that the `cat` is unnecessary - and removing it actually had some marginal gains to the naive solution. I've updated the benchmarks to show this
Cheers
So in those settings I think it's absolutely worth it
There are definitely other benchmarks that we could try as well to test other characteristics as well.
I've actually just added in this `awk` implementation you provided to the benchmarks well.
Cheers!
It's great when you quickly need to see what the distribution of classes in an input stream is. This pops up all the time. Like measuring different types of log messages, counting the variants of a field in a csv, finding the most common word or substring, etc.