Closed aep closed 6 years ago
All of the functions in futures are monomorphized for your particular usage of them, so any code that you wrote using futures combinators will show up as monomorphized futures code. Your cargo bloat
invocation above is likely showing the size of all the futures code that is generated as a result of compiling your application, as well as any of your non-futures code that is inlined into the futures functions.
So do I understand correctly that's this cannot be fixed because it's an inherit property of the typing system?
@aep The fix here is to make your application monomorphize and inline less. If you're using futures
0.1, you can consider using Box::new(your_fut) as Box<Future<Item = ..., Error = ...>>
calls to reduce monomorphization. If you're using futures-preview
0.3, you can use FutureObj::new(Box::new(...))
. More generally, flags such as opt-level=s
, opt-level=z
, and panic=abort
will tell rustc/LLVM to make optimization decisions that will result in smaller codesize,
why is futures so large? It's even bigger than std.
this is with lto, in release mode.