I have noticed that subsequent runs of grep
on the same query (and also a different query, but on the same file) are much faster than the first run (the effect is easily noticeable when searching through a big file).
This suggests that grep uses some sort of caching of the structures used for search, but I could not find a reference on the Internet.
What mechanism enables grep
to return results faster in subsequent searches?