Running this
strace -ff -tt perl -e 'open(A,"<","/proc/cpuinfo");'
gives this:
22:36:10.365187 openat(AT_FDCWD, "/proc/cpuinfo", O_RDONLY) = 3
22:36:10.382061 ioctl(3, TCGETS, 0x7fffb127ea50) = -1 ENOTTY (Inappropriate ioctl for device)
/proc/cpuinfo
is an in-memory file that does not require access to a slow disk. Why is it taking 17 ms to open?
I have tested 10 times on an idle system and the timing is very consistent.
$ uname -a
Linux hk 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
openat
already returns fd 3 at the timestamp listed. Likely there's something else going on. Wild guess would be that the process is put on hold by the CPU itself and other processes are taken care of in the mean time. I'd guess if you set priority/niceness value higher you'd see decrease in the time – Sergiy Kolodyazhnyy Jun 23 '19 at 20:59-T
option shows time durations of syscalls. Also, I've reproduced this on Linux kernel 5.1.9:openat(AT_FDCWD, "/proc/cpuinfo", O_RDONLY) = 3 <0.016822>
- 17 msec. – Danila Kiver Jun 24 '19 at 14:46