Tencent / flare

Flare是广泛投产于腾讯广告后台的现代化C++开发框架,包含了基础库、RPC、各种客户端等。主要特点为易用性强、长尾延迟低。
Other
1.33k stars 200 forks source link

Fiber scheduling takes too long #146

Closed Fin-chan closed 8 months ago

Fin-chan commented 10 months ago
auto start_time = flare::ReadSteadyClock();
flare::fiber::Async([start_time]{
    auto end_time = flare::ReadSteadyClock();
    const auto scheduling_time = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time);
    // user code
});

flare::fiber::Async() opens a fiber concatenation to execute and found that the scheduling_time is long, is there any way to analyze and optimize it?

yinghaoyu commented 10 months ago

Try to use perf.

0x804d8000 commented 10 months ago

Internals of fiber scheduling are exposed via https://github.com/Tencent/flare/blob/master/flare/doc/debugging.md .

You might be interested in https://github.com/Tencent/flare/blob/master/flare/fiber/detail/scheduling_group.cc#L72 in specific.

Please note that you need open a port via flare::Server to access these variables.

Fin-chan commented 8 months ago

I fixed the problem of long scheduling times for fiber. Thx