I just run a copy command for two large directories with a small number of huge files and I see my cp process is consuming around half a core in top:
51116 root 20 0 110m 876 688 D 43.9 0.0 3:23.83 cp -i -r 165 178 temp
Why does the cp process consume any cpu? I would imagine it spends most of it's time waiting on disk...
Thx, Boaz
if you check the percentages, at the top of the screen, you'll see that it's mostly on
%wa
(waiting) and%id
(idle), and very little (if any) in%us
(userspace).but at the process line, all the time it spends idly waiting for a given process is charged to that process. if another CPU-heavy process was running at the same time, it would take most of the CPU without affecting the copy task, because it would use the
%id
and%wa
time.It is managing the move. This includes finding the files, creating new files, and copying them. All this takes some CPU time. Due to the way files are buffered, it may be possible to this very quickly with the file writes occurring asynchronously to the copy operation. If the files aren't buffered, then the CPU utilization can be quite low while files are accessed.