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

Implement high-resolution timer infrastructure for task scheduling #69

Open
alexrp opened this issue Nov 1, 2023 · 0 comments
Open
Assignees
Labels
area: common Issues related to the shared utility APIs. state: approved Feature requests and housekeeping tasks that have been approved. type: feature Issues that are classified as feature requests.
Milestone

Comments

@alexrp
Copy link
Sponsor Member

alexrp commented Nov 1, 2023

Task.Delay() has around ~15 ms of overhead on Windows and ~10 ms on Linux. This is likely to be too much for some combat simulation tasks in the world server.

On Windows, we can implement a custom timer queue backed by CreateWaitableTimerExW (with the CREATE_WAITABLE_TIMER_HIGH_RESOLUTION flag) and SetWaitableTimer (with negative lpDueTime to avoid clock skew).

On Linux, we can use clock_nanosleep (with CLOCK_MONOTONIC_RAW to avoid clock skew) in a dedicated thread. We would need to send the thread a signal with pthread_kill when the due time needs to be updated.

@alexrp alexrp added state: approved Feature requests and housekeeping tasks that have been approved. type: feature Issues that are classified as feature requests. area: common Issues related to the shared utility APIs. labels Nov 1, 2023
@alexrp alexrp added this to the v1.0 milestone Nov 1, 2023
@alexrp alexrp self-assigned this Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: common Issues related to the shared utility APIs. state: approved Feature requests and housekeeping tasks that have been approved. type: feature Issues that are classified as feature requests.
Projects
None yet
Development

No branches or pull requests

1 participant