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

(tokio-util JoinMap) Remove raw-entry feature in favour of HashTable API. #7252

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

conradludgate
Copy link
Contributor

Motivation

While rebasing #7075, I noticed the change from #7219 which updates hashbrown, requiring the addition of the raw-entry feature. That inspired me to take a look at the actual JoinMap impl and I thought it could be improved by using HashTable instead.

Solution

Replacing the tasks_by_key map with a HashTable, we unlock a few benefits:

  1. When searching by ID, we don't need to store the id in tasks_by_key, since we can fetch the ID from the AbortHandle.
  2. We don't need to duplicate the S: BuildHasher, as we are in-control over the hash-function, we can fetch the existing hasher from hashes_by_task.

However, removing the ID from tasks_by_key will slow down those lookups (only in join_next()), as they now need a vtable lookup, rather than comparing against the id already in the current cache line.


I don't feel strongly about this PR, I'm just quite fond of the HashTable API and thought I'd try it here.

@Darksonn Darksonn added the A-tokio-util Area: The tokio-util crate label Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio-util Area: The tokio-util crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants