Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High cpu load when set heartbeat_check_interval in SWOOLE_PROCESS mode on WSL #3483

Closed
gmsj0001 opened this issue Jul 20, 2020 · 6 comments
Closed

Comments

@gmsj0001
Copy link

设置心跳检测后,PROCESS模式CPU会占用到100%,BASE模式则一切正常
生产环境的CentOS并没有发现这个问题,不知道是不是WSL的bug

@matyhtf
Copy link
Member

matyhtf commented Jul 20, 2020

@gmsj0001 请贴出你 Server 的所有配置项

@gmsj0001
Copy link
Author

gmsj0001 commented Jul 20, 2020

测试代码:

<?php
$server = new Swoole\Http\Server('0.0.0.0', 9001, SWOOLE_PROCESS);
$server->set([
    'heartbeat_check_interval' => 10,
]);
$server->on('request', function($req, $resp) {
});
$server->start();

环境:Win10 2004 WSL bash
Linux 4.4.0-19041-Microsoft #1-Microsoft Fri Dec 06 14:06:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu 20.04 LTS
PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )
Swoole 4.5.2

@matyhtf
Copy link
Member

matyhtf commented Jul 20, 2020

无法重现你的问题。请尝试清理工程,并重新编译 swoole

使用 strace 、gdb 等工具跟踪程序执行。

@twose
Copy link
Member

twose commented Jul 21, 2020

[自动回复] 为了中文搜索引擎收录以便于后人检索和Github各国友人参与理解所需,本repo只接受英文issue

中文issue请前往Swoole中文问答社区

谢谢合作!

@twose twose closed this as completed Jul 21, 2020
@gmsj0001
Copy link
Author

Finally found libc sleep failed and immediately returned in swHeartbeatThread_loop, causing 100% CPU load.
It's a bug of WSL1, see microsoft/WSL#4898
Only affect SWOOLE_PROCESS mode because SWOOLE_BASE is single thread and use epoll for checking heartbeat.

活久见,Sleep都能失败

@matyhtf
Copy link
Member

matyhtf commented Jul 21, 2020

@gmsj0001 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants