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

[PATCH v3] linux-gen: timer: enhance timer expire scalability #1871

Closed

Conversation

TianyuLi0
Copy link
Contributor

Use stash and pre-allocated memory to store tick_buf index, so timer_expire can find expire tick_buf index with hash function without walk through all tick_buf.

Addtional overhead introduced to timer start and cancel operation. Expire operation cost remain constant.

Timer set and cancel operation cycles
Base 69
Current 139

Expire operation cycles
Timer num. 10 100 1000
Base 37 38 190
Current 40 39 37

@odpbuild odpbuild changed the title linux-gen: timer: enhance timer expire scalability [PATCH v1] linux-gen: timer: enhance timer expire scalability Jul 28, 2023
@odpbuild odpbuild changed the title [PATCH v1] linux-gen: timer: enhance timer expire scalability [PATCH v2] linux-gen: timer: enhance timer expire scalability Jul 28, 2023
uintptr_t slot_addr;
int slot_index = (tick / tp->param.res_ns) % MAX_SLOT_NUM;

odp_spinlock_lock(&tp->timing_wheel.lock_pool[slot_index]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid locking on every scan call, could timer expiration first checked with relaxed reads and only when a thread finds expired timer, it would lock (or use atomics) to remove the expired timer from the data structure. Relaxed checking needs that expiration times are saved into a data structure that does not break, if another thread cancels/expires a timer simultaneuosly.

Use stash and pre-allocated memory to store tick_buf index,
so timer_expire can find expire tick_buf index with hash function
without walk through all tick_buf.

Additional overhead is introduced to start and cancel operation.
Expire operation cycle cost is constant with more timers.

Timer set and cancel operation cycles
Base     69
Current 139

Expire operation cycles
Timer num.     10   100   1000
Base           37    38    190
Current        40    39     37

Signed-off-by: Tianyu Li <tianyu.li@arm.com>
@odpbuild odpbuild changed the title [PATCH v2] linux-gen: timer: enhance timer expire scalability [PATCH v3] linux-gen: timer: enhance timer expire scalability Sep 4, 2023
@psavol psavol closed this May 2, 2024
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

Successfully merging this pull request may close these issues.

2 participants