Skip to content

Randomize thread unblocking operation #4032

@tiif

Description

@tiif

In eventfd, we would unblock multiple threads in a deterministic sequence. In epoll, we always choose the thread id from the end of the list if multiple threads are blocked on the same epoll instance. We could randomize these operation depending on the seed.

Related FIXME:

// FIXME: We can randomize the order of unblocking.
for thread_id in waiting_threads {
ecx.unblock_thread(thread_id, BlockReason::Eventfd)?;
}

// FIXME: We can randomly pick a thread to unblock.
let epoll = epfd.downcast::<Epoll>().unwrap();
if let Some(thread_id) = epoll.thread_id.borrow_mut().pop() {
waiter.push(thread_id);
};

Side note:
Blocking socketpair #3665 would need to use this too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-concurrencyArea: affects our concurrency (multi-thread) supportA-shimsArea: This affects the external function shimsC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions