-
Notifications
You must be signed in to change notification settings - Fork 252
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
core: reduce monomorphization of the futures code #2406
Conversation
Thanks for the patch it's a really interesting idea. I think we should try to think through the trade-offs here a bit more before landing this one. I hope to put together a bunchmark on async call overhead. This is my main question: how much overhead does boxing the futures add per-call? The other half of the trade-off is the binary size, can you share some details about your project so we can understand that better? Like, how many async functions are you exporting? Once we know both of those, I think we'll be in a much better position to judge this one. Maybe the boxing overhead will be small enough that we can just hit the merge button. Maybe it's a real trade-off and we should add a config option for this. |
I'll try to add some benchmark soon.
This is the project: https://github.com/rust-nostr/nostr/tree/d030b776f521fc2bb032f9490bab89e3bfbb5108/bindings/nostr-sdk-ffi I tried to count the This is the result of cargo-bloat-uniffi-b46ab54.txt While this is the result using the patch ( |
I tried to take a look at the current benches but I'm not sure how the new ones should be added |
Thanks for those details, it's very interesting to go through. I'll try to put together an async benchmark in the next week or two. |
Well, one month later and those benchmarks still aren't up. I still really want to put them together, but I've had to focus on other priorities. OTOH, you have solid numbers that this is an improvement for your use case. I'm leaning towards merge, but I'd like to get the opinion of some other UniFFI devs. @badboy @mhammond what do you think? |
I think I lean towards taking them simply because there's a known problem fixed by it, and only a lack of certainty without real evidence about side-effects. However, that lack of certainty means that I don't think it should be in a 0.29 version (or at least not the next one, but instead it should have time to bake on main) |
These changes will reduce the monomorphization of the futures, resulting in a reduction of the binary size. Signed-off-by: Yuki Kishimoto <[email protected]>
Rebased and fixed the conflicts |
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.
Thanks for the code, let's merge this one.
These changes will reduce the monomorphization of the futures code, resulting in a reduction of the binary size.
In my case, the binaries for android targets have become 100/200kb smaller.