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

Possible ways to optimize HashMap<MessageId, Message> #1484

Open
rukai opened this issue Feb 19, 2024 · 0 comments
Open

Possible ways to optimize HashMap<MessageId, Message> #1484

rukai opened this issue Feb 19, 2024 · 0 comments

Comments

@rukai
Copy link
Member

rukai commented Feb 19, 2024

HashMap<MessageId, Message> is now a common idiom in transforms for keeping track of a generated response that needs to replace the response to a certain request.
In order to optimize this I have a few ideas.

Easy idea

Replace the hasher with a faster hash, the default hash is dos resistant which we dont need since the MessageId's are purely internal.
This should actually be a pretty good win since we hash every incoming response

Implemented here #1486

Crazy Idea

  • Replace MessageId with an incrementing u64, then rewrite the hashmap as a binary search over a VecDeque.
    • this avoids hashing all together
    • I suspect that insertion + removal for a hashmap is expensive, and this will completely avoid that.

However, before attempting any of this we should wait and see if hashmap insert/remove ever appears while profiling.

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

No branches or pull requests

1 participant