-
Notifications
You must be signed in to change notification settings - Fork 57
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
Very large memory size for DateTime carrying Tz from chrono-tz #27
Comments
I have an idea for fixing this up and potentially improving the speed of the timezone calculations. I'll see if I can put together a PR of some sort this week. |
Last year I did some calculations on the minimum size needed for a It currently has the definition: pub struct TzOffset {
tz: Tz, // ~600 variants so at least 16-bit
offset: FixedTimespan,
}
pub struct FixedTimespan {
pub utc_offset: i32,
pub dst_offset: i32,
pub name: &'static str, // pointer + usize
} Combined this type needs 26 bytes with 8-byte alignment on 64-bit platforms. When added to the 12-byte How much bits do we actually need?
Combined that would put the minimum size for Optimization with a medium-sized tableCurrently we store the abbreviations as a large number of tiny slices, which adds quite some overhead to the binary. Concatenating them in a ~500 char string as I proposed above is one option. Alternatively we could make a table of all Just 11 bits is enough to index into the table and get the
|
I just want to warn that I don't think there's overwhelming evidence that the size of these types are causing problems for lots of people, so optimizations here should be carefully balanced against the amount of complexity they introduce. |
gives output:
As you can see, DateTime carrying chrono-tz's TimeZone is a very expansive structure, occupying 48 bytes. This is bad for cache utilization and is expansive when copying the structure around.
The text was updated successfully, but these errors were encountered: