romange / helio

A modern framework for backend development based on io_uring Linux interface
Apache License 2.0
447 stars 50 forks source link

fix: correctly handle cpu cycle reset events #120

Closed romange closed 1 year ago

romange commented 1 year ago

Addresses https://github.com/dragonflydb/dragonfly/issues/1705

romange commented 1 year ago

So, I'm not sure I follow about the exact reason for the high CPU: it seems we would never execute ProcessSleep? But why would that create high CPU usage?

I'm wondering if we might have a similar bug for clock adjustments.

I fixed the root cause. The bug that caused the elevated CPU usage is here: https://github.com/romange/helio/blob/master/util/fibers/uring_proactor.cc#L631-L638

scheduler->NextSleepPoint() is in the past (because it never gets processed), therefore ts_arg points to zero interval causing wait_for_cqe to constantly spin.

royjacobson commented 1 year ago

Ah, clever LOG_FIRST usage :)