Why does the program that reads files still run very fast after clearing the page cache?
0
votes
1
answer
36
views
Test environment: Virtual Machine(Windows 11, VMware Workstation Pro), Ubuntu 22.04, mechanical hard drive.
Use the following command to generate 1GB of test data:
dd if=/dev/urandom of=test.data count=1M bs=1024
Clear the cache:
sync; echo 3 > /proc/sys/vm/drop_caches
Run:
time cat test.data > /dev/null
Execution time:
real 0m14.814s
user 0m0.011s
sys 0m4.034s
Clear the cache again:
sync; echo 3 > /proc/sys/vm/drop_caches
Run:
time cat test.data > /dev/null
Execution time:
real 0m1.761s
user 0m0.020s
sys 0m1.679s
Run immediately again (without clearing cache):
time cat test.data > /dev/null
Execution time:
real 0m0.227s
user 0m0.009s
sys 0m0.218s
After clearing the cache, I checked /proc/meminfo to confirm that the cache was indeed cleared.
Why is the second run still significantly faster even after clearing the cache?
Screenshot of the execution process:

Asked by 沈小伟
(1 rep)
May 22, 2025, 02:42 AM
Last activity: May 23, 2025, 04:02 PM
Last activity: May 23, 2025, 04:02 PM