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

Mix usage of different clock source #2865

Open
BusyJay opened this issue Jan 8, 2025 · 0 comments
Open

Mix usage of different clock source #2865

BusyJay opened this issue Jan 8, 2025 · 0 comments

Comments

@BusyJay
Copy link
Contributor

BusyJay commented Jan 8, 2025

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.

inline int futex_wait_private(
void* addr1, int expected, const timespec* timeout) {
return syscall(SYS_futex, addr1, (FUTEX_WAIT | FUTEX_PRIVATE_FLAG),
expected, timeout, NULL, 0);
}

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 (更多上下文/截图)

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

No branches or pull requests

1 participant