-
Notifications
You must be signed in to change notification settings - Fork 175
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
Datagen: Cache supported_locales impls #4470
Conversation
Based on the flamegraph, it seems after this lands the next bottlenecks might be:
|
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.
observation: DatagenDriver
already calls supported_locales
exactly once per key, so this is a DatagenProvider
-internal issue.
provider/datagen/src/provider.rs
Outdated
@@ -306,6 +309,28 @@ pub struct SourceData { | |||
pub(crate) icuexport_dictionary_fallback: Option<Arc<SerdeCache>>, | |||
#[cfg(feature = "legacy_api")] | |||
pub(crate) collations: Vec<String>, | |||
pub(crate) supported_locales_cache_vec: |
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.
Use an Arc
?
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.
Switched to Arc
.map_err(|e| *e) | ||
} | ||
|
||
fn supports_locale(&self, locale: &DataLocale) -> Result<bool, DataError> { |
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.
supports_locale
is called n times per key, whereas supported_locales
is only called once. It probably makes more sense to cache a HashSet
and convert it to a Vec
for the one call, than to linearly scan a Vec
n times.
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.
n.b. we don't run this in google3 anyway |
provider/datagen/src/provider.rs
Outdated
FrozenMapThrowawayClone<DataKey, Box<Result<Vec<DataLocale>, DataError>>>, | ||
} | ||
|
||
pub(crate) struct FrozenMapThrowawayClone<K, V>(pub(crate) FrozenMap<K, V>); |
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.
I believe elsa
master has these impls now
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.
It does for sync
at least.
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.
elsa 1.10
should work.
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.
Upgraded to elsa 1.10
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.
r=me with the change from vec to hashset
Changelog in #4484 |
cargo make bakeddata datetime
performance on my machine:On main: 173.91 seconds.
On this branch: 62.24 seconds.
Still slow but it seems to be substantially faster.