Why is read to memory three times slower than read to /dev/null?

Viewed 133

I would like to read files fast from my disk, I have tried three methods:

  1. bash: cat file_path > /dev/null
  2. d: auto data = read(file_path);
  3. bash: rsync -av -P file_path path_to_fast_file_system

Method 1. reads at 470MB/s, which is ok speed wise, but the files end up in /dev/null which is not suitable for my needs. Method 2. and 3. read at 140MB/s which is slow, but they do what I need.

Why is it three times slower to read into memory than to read into /dev/null? Please let me know how I can read the data of a file at the same speed as cat to /dev/null but into memory or through rsync?

0 Answers
Related