创建虚拟机,发现virsh edit很慢。
strace的结果:
09:26:03 close(10) = -1 EBADF (Bad file descriptor)
09:26:03 close(11) = -1 EBADF (Bad file descriptor)
09:26:03 close(12) = -1 EBADF (Bad file descriptor)
09:26:03 close(13) = -1 EBADF (Bad file descriptor)
。。。。。----------------------strace的时候中间耗时很长,不strace为30s
09:35:49 close(20479995) = -1 EBADF (Bad file descriptor)
09:35:49 close(20479996) = -1 EBADF (Bad file descriptor)
09:35:49 close(20479997) = -1 EBADF (Bad file descriptor)
09:35:49 close(20479998) = -1 EBADF (Bad file descriptor)
09:35:49 close(20479999) = -1 EBADF (Bad file descriptor)------到此一直在关闭fd,
这个值取决于# ulimit -n
20480000
可以看出,耗时主要在关闭不存在的fd,由于这些fd不可能都被打开了,所以很明显这个是一个bug。
具体的bug可以参考如下:
2019-10-14 - Jiri Denemark jdenemar@redhat.com - 4.5.0-23.el7_7.2
-
- virNetDevOpenvswitchInterfaceStats: Optimize for speed (rhbz#1760470)
-
- test: Introduce virnetdevopenvswitchtest (rhbz#1760470)
-
- vircommand: Separate mass FD closing into a function (rhbz#1760470)
-
- virCommand: use procfs to learn opened FDs (rhbz#1760470)
-
- util: command: Ignore bitmap errors when enumerating file descriptors to close (rhbz#1760470)
-
- util: Avoid possible error in virCommandMassClose (rhbz#1760470)
[]# ulimit -a
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 1540685
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 20480000
[]# ulimit -n
20480000
也就是bug是两方面触发的,一方面是ulimit设置的-n值非常大,而是代码循环去关闭了本就没打开的fd。
手机扫一扫
移动阅读更方便
你可能感兴趣的文章