kadina
kadina

Reputation: 5382

why grep command is taking less time when performing second time?

When I do grep on a large local file, it took long time. But when I do it again, now it is much faster. Is this behaviour because of some type of internal cache maintained by Linux systems?

Upvotes: 3

Views: 363

Answers (2)

Jesus Ramos
Jesus Ramos

Reputation: 23266

The virtual memory page cache will keep copies of pages from the disk in your RAM which means the access time is faster and the corresponding read/pread calls will be serviced from memory instead of having to go to disk.

Upvotes: 2

MTilsted
MTilsted

Reputation: 5543

Yes. All free ram is be used to cache data read from your harddisk.

Upvotes: 6

Related Questions