-
Notifications
You must be signed in to change notification settings - Fork 548
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
Replace hash maps with fast hash maps #2150
Conversation
Using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for optimizing this! I'm looking forward to see how Dota improves :)
In the meantime, there is a few comments to address and CI to fix before we proceed with merging.
src/backend/metal/src/device.rs
Outdated
@@ -6,17 +6,19 @@ use {conversions as conv, command, native as n}; | |||
use native; | |||
|
|||
use std::borrow::Borrow; | |||
use std::collections::hash_map::{Entry, HashMap}; | |||
use std::collections::HashMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change? it's the same as the old code but more verbose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I need to combine these again. Originally HashMap
was removed entirely then I realized we still need it for the spirv_cross overrides
src/hal/src/lib.rs
Outdated
@@ -55,6 +56,9 @@ pub mod queue; | |||
pub mod range; | |||
pub mod window; | |||
|
|||
#[doc(hidden)] | |||
pub mod auxil; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, it appears to me that backend
has a very similar goal. Should we move the fast hashmap into backend
?
src/backend/metal/src/lib.rs
Outdated
@@ -12,6 +12,7 @@ extern crate core_graphics; | |||
extern crate block; | |||
extern crate smallvec; | |||
extern crate spirv_cross; | |||
extern crate fxhash; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does Metal need this explicitly? I'd assume it to just use the types exported from hal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, just left it there accidentally
CI failure seems unrelated, I'll rebase now |
thanks! |
2150: Replace hash maps with fast hash maps r=kvark a=grovesNL Fixes #2148 PR checklist: - [X] `make` succeeds (on *nix) - [X] `make reftests` succeeds - [X] tested examples with the following backends: Metal/GL/DX12/Vulkan Changes: - Replaced `HashMap` with `FastHashMap` type (uses `FxHash`) - Changed `Queues` to use a `Vec` instead of `HashMap`. It doesn't seem like a `HashMap` is necessary here, and the family ID is already present within the queue group, if I understand correctly. But this seems trivial overall because this shouldn't be a hot path ever. - mtl: Changed bindings to use a `Vec` (holey, filled with potentially a lot of `None`) indexed by binding. Not sure if this is the best approach but it should provide fast iteration and lookup by binding Overall this seems to give a pretty good improvement in Dota 2 as far as I can tell from profiling. I don't have precise benchmarks. Co-authored-by: Joshua Groves <[email protected]>
Fixes #2148
PR checklist:
make
succeeds (on *nix)make reftests
succeedsChanges:
HashMap
withFastHashMap
type (usesFxHash
)Queues
to use aVec
instead ofHashMap
. It doesn't seem like aHashMap
is necessary here, and the family ID is already present within the queue group, if I understand correctly. But this seems trivial overall because this shouldn't be a hot path ever.Vec
(holey, filled with potentially a lot ofNone
) indexed by binding. Not sure if this is the best approach but it should provide fast iteration and lookup by bindingOverall this seems to give a pretty good improvement in Dota 2 as far as I can tell from profiling. I don't have precise benchmarks.