alehro
alehro

Reputation: 2208

Why first run of grep is several times slower than consecutive runs?

I run this command every time I build my project from the project directory:

egrep -r -n --include=*.java <my regex> .

And I cannot understand why consecutive runs are up to 10 times faster than first one. Actually I have seen this behavior in other disk IO operations involving large directories (calculation directory size, code commits etc.). I think that it is related to operation system's disk IO internals. Probably it is caching on some level. Can somebody point my nose in right direction?

Upvotes: 1

Views: 122

Answers (1)

Heisenbug
Heisenbug

Reputation: 39194

Because recently accessed files are cached by the operating system.

Have a look here.

Upvotes: 4

Related Questions