Editor's note: This is the original author of GNU grep Mike Haertel in FreeBSD mailing lists to answer made 'GNU grep Why faster than BSD grep', the following is the content of the message body: Gabor Hello, I was the original author of GNU grep , but also a FreeBSD user, but I have been using -stable version (that is, older versions), but not how attention -current version. However, when I accidentally read -current version mailing list, stumbled upon some discussion about BSD grep and GNU grep performance, you might have noticed those discussions. Anyway, the only reference to it, here are some simple Air Max 2012 White Black Grey conclusion about why GNU grep so fast. Maybe you can learn some thought applied Air Max 2012 Yellow Black Grey to BSD grep go. Tips # 1: GNU grep reason why fast is because it does not go to check the input each byte. Tips # 2: GNU grep reason is fast because it does need to check each byte that are executed very little instruction (operation). GNU grep uses very famous Boyer-Moore algorithm (Translator's Note: BM algorithm is a very efficient string search algorithm, under normal circumstances, 3-5 times faster than KMP algorithm, you can see this on the very specific Detail of the Nike 6.0 Mavrk Mid 2 Skate Shoes Blue Grey article: grep the Boyer-Moore string search algorithm implemented progressively (3-5 times faster than KMP)), the algorithm first start looking from the last character of the destination string, and using a look-up table, it can be character after a match was found not to calculate how much you can skip input characters and continue the search. GNU grep also launched an internal circulation Boyer-Moore algorithm, and the establishment of a Boyer-Moore's delta table, so that it does not need to be expanded every step loop exit judgment. The result is that, in extreme circumstances (in the limit), x86 GNU grep command on the need to check each input byte will not be performed more than three (and also skipped a number of bytes). You can look at the Andrew Hume and Daniel Sunday 1991 in November 'Software Practice \u0026 amp; Experience' on the papers 'Fast String Searching', this paper discusses good Boyer-Moore algorithm to achieve skills, this paper has free PDF online edition (Translator's Note: Click here to view or download). Once you have a quick search, then you will also need to find the same fast input. GNU grep input using native Unix system calls and Air Jordan Outlet avoid after reading a copy of the data. Moreover, GNU grep also avoids the input branch, grep will find line breaks several times to slow down, because looking newline you must look at each byte! So do not use GNU grep input-based line, but the original data is read into a large buffer buffer, using the Boyer-Moore algorithm to search for the buffer, only after finding a BHM Lebron 12 Black White-Metallic Silver match will go to find the latest wrap character (some command parameters, such as -n disables this optimization). Finally, New Womens Nike Free 3 V3 Trainers Black Grey when I was still maintaining GNU grep time (15+ years ago ......), GNU grep also try to do some very difficult things can be avoided so that the core of each byte process input, such as using mmap () instead read () for file input. At that time, with the Air Max 2012 Womens Navy Blue White read () will most Unix versions cause some extra copies. Because I no longer GNU grep, so it seems 2015 Nike Free 5.0 no longer mmap default, but you can still enable it through parameter -mmap, at least in the buffer cache file system has been under the circumstances of your data, mmap still faster: $ time sh -c 'find -type f -print | xargs grep -l 123456789abcdef.' real0m1.530s user0m0.230s sys0m1.357s $ time sh -c 'find -type f -print | xargs grep -. mmap -l 123456789abcdef 'real0m1.201s user0m0.330s sys0m0.929s [input here is a 648M for MH Nike Free 4.0 V3 Men mail folder that contains information about 41000] So even today, you can still use -mmap speed of more than 20%. Summary: Air Max 2012 Womens Navy Blue White - Use the Boyer-Moore algorithm (and expand it to the inner loop). - The use of native system calls to build your buffered input, to avoid input bytes before the search copy. (In any Nike Free 4.0 V2 Women case, it is preferable to use the buffer output, because a common scene in grep, the output is less than input, so the output buffer copy overhead to be small, and you can BHM PE Black History Month Nike Lunar Hyperdunk Low Online save a lot of such small unbuffered Nike Air Max writes.) - Air Jordan Heel In Before a match Air Max 2012 Purple Black is found, do not look for a line break. - Try to do some settings (such as page-aligned buffer, according to the page size to read the block, selective use mmap), so you can make the kernel prevent copy bytes. Make the program faster key is to let them do fewer things. ;-) Sincerely Mike GNU grepWhy so fast?