apache / apache/brpc

EventDispatcher Run调用epoll_wait导致cpu持续高

Open
#1,710 1 comment 0 reactions 0 assignees View on GitHub
performance
Dominant language
C++
Stars
17.6k
Forks
4.1k
Avg merge
2d 12h
Merged PRs (30d)
69

Description

**Describe the bug (描述bug)**
我有一个主服务,会启动一个bthread线程执行某些脚本,过程中会有一些fork行为。此外会启动另一个bthread线程,来获取脚本进程的系统资源使用(cpu、rss等)。当触发某些条件时,会杀掉脚本进程组,两个bthread线程会自行退出。

但是当bthread线程return后,主服务进程的cpu便会持续升高,gdb发现有一个LWP会call EventDispatcher,一个持续epoll_wait的行为会占满100%cpu,并且LWP的id会发生变化。

top -Hp信息

gdb信息:

perf top信息:

bthread前后信息:
运行时信息:

杀死脚本进程,两个bthread退出后信息:

**To Reproduce (复现方法)**

**Expected behavior (期望行为)**
导致cpu升高的原因是什么,如何避免?

**Versions (各种版本)**
OS: linux 4.19
Compiler: gcc-4.9.2
brpc: 0.9.7
protobuf: 2.4.1

**Additional context/screenshots (更多上下文/截图)**

Contributor guide

Open the contributing guide

Research direction

Start with the EventDispatcher path around epoll_wait and compare its behavior before and after the two bthread threads return. Determine why the main process reaches sustained high CPU and document a reproducible cause and avoidance strategy for the listed brpc, Linux, and compiler versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.