gpt4 book ai didi

linux - epoll_wait() 占用太多 CPU

转载 作者:太空狗 更新时间:2023-10-29 12:10:20 38 4
gpt4 key购买 nike

我的 epoll_wait() 消耗了过多的 CPU,一个简单的 strace 显示:

    strace -c -f -p 3655
Process 3655 attached with 5 threads
^CProcess 3655 detached
Process 3656 detached
Process 3657 detached
Process 3658 detached
Process 3659 detached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
64.43 32.228205 596819 54 epoll_wait
35.31 17.661939 17 1063312 195547 futex
0.26 0.131803 0 448140 gettimeofday
0.00 0.000090 3 27 write
0.00 0.000050 1 54 epoll_ctl
0.00 0.000000 0 54 27 read
0.00 0.000000 0 9 sendmsg
0.00 0.000000 0 90 54 recvmsg
------ ----------- ----------- --------- --------- ----------------
100.00 50.022087 1511740 195628 total

epoll_wait() 调用只有 54 次,但是 epoll_wait() 的 usecs/call 是 596819,为什么?

最佳答案

在这种情况下,strace 报告的时间有点误导。

strace(1)告诉我们:

-c Count time, calls, and errors for each system call and report a summary on program exit. On Linux, this attempts to show system time (CPU time spent running in the kernel) independent of wall clock time.

但我怀疑它实际计算的只是从 epoll_wait 被调用到它返回的时间。这并不意味着您的进程在内核中“正在运行”。它更有可能在 sleep ,这对于 epoll_wait 来说是很自然的。

关于linux - epoll_wait() 占用太多 CPU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47630538/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com