-
Notifications
You must be signed in to change notification settings - Fork 213
Reducing size of DateTimeFormatter and other large objects #3413
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
Comments
Two other options that came up during discussion:
|
In any of these modes that involves boxing the data struct for postcard users, it would be nice if they could work with a cache of deserialized postcard objects (the cache owns the heap-allocated objects and the formatters reference them out of the cache). Haven't thought through how it would work exactly. |
Discuss with: |
Related: #3020 |
|
I don't see a way to get to 16 for a cowable slice. In the non-null case, both the borrowed and the owned variants need two full usizes. The only niche is when the pointer is exactly 0, which is sufficient for |
We could for example make the assumption that our strings will at most be half a usize long. |
Maybe, but then we technically need fallible conversions from |
Talking about map_project issue
Options for fixing datetimeformat size itself:
@sffc For option 1 it's a bunch of tricky custom deser impls, maybe just wait for 2.0 and Better Sliced Symbols. Let's do number 4 (new data payload) and we're doing number 3 anyway (pattern interpolator). We can do Numbers 1 and 2 in the 2.0 timeframe. Number 2 needs investigation. Decision: @sffc @Manishearth @younies @robertbastian @skius (@eggrobin 😕) Milestones: @sffc hoping to get the new pattern interpolator done in 1.4. New data payload thingy should be Q3, 1.x Priority. manish to file issues |
All the sub-issues are done, and the 2.0 DateTimeFormatter (YMD mode) is 384 bytes, a 94% improvement from 1.5. So I am going to mark this as fixed. |
Uh oh!
There was an error while loading. Please reload this page.
DateTimeFormatter is 6.6 KB on the stack. This is because it owns a lot of DataPayloads, which are themselves collections of pointers to strings either in bake data or in a postcard buffer. In total, there are hundreds of strings in DateTimeFormatter that may or may not be present in a particular instance.
This is more impactful in C++ than in Rust, because we put the DateTimeFormatter on the heap when returning it to C++.
A few options:
&'static
reference.--all-features
try_new_with_static_provider
which would return the formatter in small-stack mode. BakedDataProvider would implement a trait that can be used with this new function.CC @Manishearth @robertbastian
Update (29-06-2023)
Sub-issues:
Pre-2.0:
Post-2.0:
The text was updated successfully, but these errors were encountered: