-
Notifications
You must be signed in to change notification settings - Fork 185
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
Reduce stack size of DataPayload #4438
Comments
I should note that |
This would have to be the other way around, using default features. Which also has problems here. |
Yeah that's what I meant, sorry. icu_provider gets a feature to enable the Yoke variant. BlobProvider enables the feature. Also any crates using map_project enable the feature, which is DateTime but we're getting rid of that code soon. But again this doesn't work with global feature resolution so I'm inclined to not do it right now. |
Ideally I want a ShortVec of DataPayload to fit in one word plus the struct size. Here's how:
This works so long as 0x1 is not a valid address for an Rc which it shouldn't be due to alignment. |
Here's a fully safe type And here's the |
This is incorrect: The I don't think 3 will happen anytime soon. I think 2 will have a relevant perf impact and it's going to be tricky to do in a generic context (it's basically impossible to write your own niche logic like "Yoke uses this bitpacking but only when the cart type looks like this", and it breaks parametricity) I'm not super happy about 1 either since it pessimizes postcard, personally I'd rather not do this than do any of the changes here. |
Yes. My sentence was correct but incomplete. Postcard already uses an Arc, so there's no difference for Postcard, only a difference when using
Ok. How hard is it? Is it blocked on bandwidth or on more fundamental design concerns?
Did you review the specific proposal for 2 that I posted in the sandbox in my previous reply?
I don't think it pessimizes postcard. It pessimizes custom data adapters and components that use map_project or similar, which will be none after the datetime refactor. However I'm not super happy about it either. |
I'm not too concerned adding an extra branch or few cycles to this especially since we've designed our APIs with the assumption that |
Unclear, it's not even in the stage of discussion where it's something the lang/compiler teams are tracking. It's an idea someone had that garnered some discussion, with some positive-to-neutral comments from team members but nothing concrete. Someone needs to put in the effort to talk to the teams and maybe write a proper RFC. It'll still be blocked on bandwidth then. There may be perf tradeoff concerns but probably not for this particular optimization.
Ah I see. Yeah I guess.
It doesn't do it in a generic context. You're using specific types there, there's no way to fit that into I'm not a huge fan of having extra Yoke types that are not Yoke: the Yoke logic is quite self-contained and I'd like to keep it that way.
Yeah in that case I think 1 is probably the best path forward but I'm still not happy about it and not sure if we should do this at all. |
With the |
I'm fine with this.
I assume this is what the open PR does? I don't like how much unsafe code that adds.
Very opposed. Global feature resolution means it will be tricky and brittle to actually get this size reduction. |
Currently DataPayload adds 2
usize
s of stack space on top of the data struct.A DataPayload looks like this:
The
Option<Arc<Box<[u8]>>>
fits in a single word, and the enum discriminant takes the whole other word.We should aim to get the size impact down to a single word.
Some potential options:
Option<Arc<Box<[u8]>>>
toArc<Option<Box<[u8]>>>
. This requires allocating a pointer when creating a data payload viaDataPayload::new_owned
or when usingDataPayload::with_mut
, neither of which are used in the most common code paths (baked data and immutable postcard data). PlaygroundThoughts? @Manishearth @robertbastian
The text was updated successfully, but these errors were encountered: