brpc icon indicating copy to clipboard operation
brpc copied to clipboard

Mix usage of different clock source

Open BusyJay opened this issue 11 months ago • 1 comments

Describe the bug (描述bug)

All APIs that accept timeout say the timeout should be measured in clock_realtime. However, under the hook, brpc uses futex syscall to wait for a specific time.

https://github.com/apache/brpc/blob/4c33f886756689d6ae90905c5f0cc6fef97e90cf/src/bthread/sys_futex.h#L38-L42

And according to https://www.man7.org/linux/man-pages/man2/futex.2.html, futex uses clock_monotonic clock by default.

To Reproduce (复现方法)

Expected behavior (期望行为)

Use the same clock source for all timeouts. Better use clock_monotonic as it's efficient and has some degree of defense against system time jump.

Versions (各种版本) OS: Compiler: brpc: protobuf:

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

BusyJay avatar Jan 08 '25 08:01 BusyJay

Related issue: #2763

chenBright avatar Feb 28 '25 06:02 chenBright