<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 27, 2018 at 9:24 AM, Nicholas Alexander <span dir="ltr"><<a href="mailto:nalexander@mozilla.com" target="_blank">nalexander@mozilla.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thom,<br><div><div class="gmail_extra"><br><div class="gmail_quote"><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><snip><br><br></div></blockquote></span></div></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div></div><div dir="ltr">The next idea I had is that a lot of the libraries we import seem to involve networking. The only network code we have is in `tolstoy`, which is very experimental and not something we're planning on using in production. Moving this to live under a `feature` flag reduces our size to 7396480 bytes, 4571776 bytes after strip.<br></div></blockquote><div><br></div></span><div>The WIP branch that Grisha and I are working on includes a "syncable" feature that does this, so we'll handle being able to avoid Hyper, etc in the very near future. But thanks for the reminder!<br></div></div></div></div></div></blockquote><div><br></div><div>Oh, yeah, that's a much more sensible name than actually exposing the `tolstoy` name to consumers of mentat.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote"><div></div><span class="gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I also noticed a few libraries that had multiple versions built. Specifically `regex` seems like it might be heavy (at the very least, it has dependent crates), and we're building both 0.2 and 1.0.1 (the former is specified by mentat_query_sql, and the latter by env_logger). Moving both of these to be 1.0.1 brings the size down to 6565472 bytes, 4036968 after strip.<br><br>(Worth noting that regex is a transitive dependency from `env_logger`, which I suspect we aren't thrilled with, and the use of it inside mentat_query_sql could probably be <a href="https://github.com/mozilla/mentat/blob/master/query-sql/src/lib.rs#L567" target="_blank">trivially rewritten</a> to avoid the dependency.)<br></div></blockquote><div><br></div></span><div>I filed a few issues rooted at <a href="https://github.com/mozilla/mentat/issues/772" target="_blank">https://github.com/mozilla/<wbr>mentat/issues/772</a>. We should definitely cull `regex`, but `env_logger` is an application choice more than a Mentat choice.<br></div></div></div></div></div></blockquote><div><br></div><div>Yeah. I mean, mentat probably shouldn't be depending on it though (admittedly I'm not sure that we are outside of the CLI, or where we are if so -- I haven't checked). If the application wants to that's fine. I also suspect we want a different log configuration scheme for Android and iOS, one that's more configurable at runtime. This is unrelated though.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote"><div></div><span class="gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">There are probably other targets for this (the `memchr` lib seems to be included twice, but while I've done exactly no checking, my gut says it doesn't have the same heft as `regex`).<br></div></blockquote><div><br></div></span><div>Is it possible to estimate a size metric for each of our dependencies? Yes, it's difficult with LTO/inlining/dead code removal, but it would help gauge where to put effort.<br></div></div></div></div></div></blockquote><div><br></div><div><a href="https://crates.io/crates/cargo-bloat">Cargo-bloat</a> seems to do this. Note that it seems to have a bug where it gives you the size of the
binary compiled to generate proc macros if you don't pass `--bin`
though, which I've filed <a href="https://github.com/RazrFalcon/cargo-bloat/issues/22">on their bug tracker.</a><br></div><div><br></div><div><a href="https://gist.github.com/thomcc/38f832911ab11624fab0aa8dd472a516">Here</a> are my findings for it on the mentat cli (after the work documented in this mailing list – for comparison <a href="https://gist.github.com/thomcc/ef7090b6b9d3c5c202c7e79635f27d4a">this</a> is before my fixes, which gives you some indication on things it's good at and not). It also has a mode where it tells you which functions are responsible for this (included), but it's mostly the same result here (in the 'before-fixes' version of this output there's a hint that we have two `regex` crates in that the same functions appear more than once from it, but that's about it – it would be nice if these were better called out but oh well).<br></div><div><br></div><div dir="ltr">We might also want to try the tool it's based on, <a href="https://github.com/google/bloaty">Bloaty McBloatFace</a>, which (presumably) has no rust-specific support, but seems to have more features, such as giving size profiles more types of libraries, breaking down which sections things are showing up in (cargo-bloat only understands `.text`, although it does say how big the non-.text part is), etc.<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"><div><br></div></span>Thanks for getting this started!</div><div class="gmail_quote">Nick</div><div class="gmail_quote"><br></div></div></div></div>
</blockquote></div><br></div><div class="gmail_extra">NP, I enjoy digging into this sort of stuff.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">- Thom<br></div></div>