I'm actually more familiar with the KMP algorithm than BM. So I looked it up to see what the difference was: The classic Boyer-Moore algorithm suffers from the phenomenon that it tends not to work so efficiently on small alphabets like DNA. The skip distance tends to stop growing with the pattern length because substrings re-occur frequently. By remembering more of what has already been matched, one can get larger sk…
Why GNU grep is fast (2010)
101–110 of 133 posts
Re: Why GNU grep is fast (2010)
#102The fastest programs are the ones that don't prepare themselves to do something and then don't do that thing. Another way to say just do one thing well.
The fastest programs return 0 immediately and don't do shit.
Re: Why GNU grep is fast (2010)
#103The inverse is this...what is modern software doing that makes them so slow?
I see the same in some of our software. One of our senior is rolling out a number of very, very fast collections based on compare-and-swap-operations, but you always end up thinking an hour or two about five lines of code. Most problem domains don't need this kind of performance, so most software teams don't pay the maintenance price and I think they are correct about that judgement call.
Re: Why GNU grep is fast (2010)
#104The inverse is this...what is modern software doing that makes them so slow?
Portability and maintainability, if you want to boil it down to the core. The speed of gnu grep probably isn't portable since it relies on the kernel to do certain things in a cooperative manner, and it certainly won't be easy to maintain while staying fast. I see the same in some of our software. One of our senior is rolling out a number of very, very fast collections based on compare-and-swap-operations, but you al…
Re: Why GNU grep is fast (2010)
#105Earlier quoted context omitted.
There is a third one, at low level: make it do something else. For example, programmer requests a multiplication, compiler generates a shift; programmer requests a division, compiler generates a multiplication; programmer specifies a switch, compiler generates a jump table.
I'd argue that's just a variation of doing less, in the same way that e.g. vectorization is a variation of parallelism.
Re: Why GNU grep is fast (2010)
#106Earlier quoted context omitted.
I think Kent was being sarcastic - his point is that it's rather pointless to optimize until the system is producing correct results. He's also famous for the "Make it work, make it right, make it fast" quote.
'Compile, conform, perform'
Re: Why GNU grep is fast (2010)
#107Earlier quoted context omitted.
$ touch foo $ chmod +x foo $ ./foo $ echo $? 0
For me, the trivial C program appears to run faster than the empty file: $ touch empty $ chmod +x empty $ time ./empty real 0m0.002s user 0m0.000s sys 0m0.000s $ echo "int main(){return 0;}" > trivial.c $ gcc trivial.c -o trivial $ time ./trivial real 0m0.001s user 0m0.000s sys 0m0.000s Timing results are consistent over several repetitions (provided everything's in cache from disk). Linux x86_64. `mov` takes ten tho…
$ touch empty
$ chmod +x empty
$ time ./empty
real 0m0.005s
user 0m0.001s
sys 0m0.001s
$ echo "int main(){return 0;}" > trivial.c
$ gcc trivial.c -o trivial
$ time ./trivial
real 0m0.002s
user 0m0.001s
sys 0m0.002sRe: Why GNU grep is fast (2010)
#108Impressive, but if the goal is for BSD to have a faster grep then clearly the solution is to use GNU grep instead of rolling their own redundant and inferior clone.
presumably GNU grep is GPL and incompatible with their BSD license
It's just that the end result is then restricted by the GPL, and they don't want that.
Re: Why GNU grep is fast (2010)
#109Re: Why GNU grep is fast (2010)
#110Earlier quoted context omitted.
[deleted]
I think Kent was being sarcastic - his point is that it's rather pointless to optimize until the system is producing correct results. He's also famous for the "Make it work, make it right, make it fast" quote.
A quick scholar.google.com search found a match in Byte magazine from 1983:
> Furthermore, many C environments contain measurement tools that enable the programmer to identify these critical sections easily. But the strategy is definitely: first make it work, then make it right, and, finally, make it fast.
The Google URL is http://books.google.com/books?ei=dtOXUoCVHoegkAef9YGQBg&id=A... but that's not enough to tell who wrote it. The full text is at http://archive.org/stream/byte-magazine-1983-08/1983_08_BYTE... . Unfortunately, it's OCR'ed, with advertisements and articles intermixed.
I believe it was written by James Joyce.
In any case, it looks like Beck was a ~22 year old undergraduate at the University of Oregon when that was published.