<div dir="ltr"><div>Hi Folks!</div><div><br></div><div>The Fission MemShrink project has been chugging along quite nicely and a ton of progress has been made over the past month. There's been a large focus on reducing the JS memory usage and we've managed to drop the <a href="https://treeherder.mozilla.org/perf.html#/graphs?timerange=2592000&series=autoland,1684872,1,4">base content JS measure</a> by ~1.1MB (17%) [1]:</div><div><br></div><div><img src="https://screenshotscdn.firefoxusercontent.com/images/c5046573-91bd-4ca1-98db-6290777e70c4.png" alt="https://screenshotscdn.firefoxusercontent.com/images/c5046573-91bd-4ca1-98db-6290777e70c4.png" class="gmail-transparent" style="margin-right: 0px;"></div><div><br> </div><div>Additionally we've started looking at <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1476432">the overhead of our many threads</a> [2], drafted up some ideas on <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1470591">reducing relocation overhead by adopting a fork server</a> on linux/mac [3], and we're looking at reducing the overhead of <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=648417">per process font related data</a> [4].<br></div><div><br></div><div>Below is a sampling of the bugs that have improved memory usage over the past month, apologies if I left any off! Please feel free to point out other improvements. All numbers are <i>per content process</i>.<br></div><div><br></div><div><b>JS improvements</b></div><div><ul><li>In a great example of every little bit counts, <b>Kris Maglione</b> reduced memory usage by <b>405KB</b> in various bugs that made us lazily load JS content (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1472491" style="text-decoration:none" id="gmail-docs-internal-guid-13fdd400-7fff-c701-d55f-c151b4913d10"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1472491</span></a><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-alternates:normal;font-variant-east-asian:normal;font-variant-numeric:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">, </span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1473631" style="text-decoration:none"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1473631</span></a><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-alternates:normal;font-variant-east-asian:normal;font-variant-numeric:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">, </span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1474139" style="text-decoration:none"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1474139</span></a><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-alternates:normal;font-variant-east-asian:normal;font-variant-numeric:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">, </span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1474155" style="text-decoration:none"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1474155</span></a><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-alternates:normal;font-variant-east-asian:normal;font-variant-numeric:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">, </span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1479241" style="text-decoration:none"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1479241</span></a><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-alternates:normal;font-variant-east-asian:normal;font-variant-numeric:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">, </span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1479245" style="text-decoration:none"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1479245</span></a><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-alternates:normal;font-variant-east-asian:normal;font-variant-numeric:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">, </span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1479309" style="text-decoration:none"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1479309</span></a><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-alternates:normal;font-variant-east-asian:normal;font-variant-numeric:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">, </span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1479310" style="text-decoration:none"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1479310</span></a><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-alternates:normal;font-variant-east-asian:normal;font-variant-numeric:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">, </span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1479312" style="text-decoration:none"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1479312</span></a><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-alternates:normal;font-variant-east-asian:normal;font-variant-numeric:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">, </span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1479313" style="text-decoration:none"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1479313</span></a><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-alternates:normal;font-variant-east-asian:normal;font-variant-numeric:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">, </span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1479318" style="text-decoration:none"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1479318</span></a><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-alternates:normal;font-variant-east-asian:normal;font-variant-numeric:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">, </span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1480319" style="text-decoration:none"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1480319</span></a><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-alternates:normal;font-variant-east-asian:normal;font-variant-numeric:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">, </span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1480327" style="text-decoration:none"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1480327</span></a><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-alternates:normal;font-variant-east-asian:normal;font-variant-numeric:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">, </span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1483363" style="text-decoration:none"><span style="font-size:10pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Bug 1483363</span></a>)</li><li>Kris also reduced memory usage by <b>494KB</b> by getting rid of MessageManager globals (<span style="font-size:10pt;font-family:Arial;text-decoration:underline;color:rgb(17,85,204)"><a class="gmail-in-cell-link" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1480244" target="_blank">Bug 1480244</a></span>)<br></li><li><b>Felipe Gomes</b> reduced memory usage by <b>95KB</b> by lazily loading JS content (<span style="font-size:10pt;font-family:Arial;text-decoration:underline;color:rgb(17,85,204)"><a class="gmail-in-cell-link" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1369466" target="_blank">Bug 1369466</a></span>, <span style="font-size:10pt;font-family:Arial;text-decoration:underline;color:rgb(17,85,204)"><a class="gmail-in-cell-link" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1470324" target="_blank">Bug 1470324</a></span>)</li><li><b>Mike Kaply</b> reduced memory usage by <b>65KB</b> by converting an add-on to in tree telemetry (<span style="font-size:10pt;font-family:Arial;text-decoration:underline;color:rgb(17,85,204)"><a class="gmail-in-cell-link" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1475571" target="_blank">Bug 1475571</a></span>)</li><li><b><span style="font-size:10pt;font-family:Arial">Dão Gottwald</span></b> reduced memory uasge by <b>57KB</b> by lazily generating thumbnails for the Ctrl+Tab panel (<span style="font-size:10pt;font-family:Arial;text-decoration:underline;color:rgb(17,85,204)"><a class="gmail-in-cell-link" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1481321" target="_blank">Bug 1481321</a></span>)<br></li><li><b>Nick Nethercote</b> reduced memory usage by <b>44KB</b> by making mozilla::HashMaps lazily allocate their storage (<span style="font-size:10pt;font-family:Arial;text-decoration:underline;color:rgb(17,85,204)"><a class="gmail-in-cell-link" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1481998" target="_blank">Bug 1481998</a></span>)</li><li><b>Benjamin Bouvier</b> reduced memory usage by <b>25KB</b> by removing SIMD.js (<span style="font-size:10pt;font-family:Arial;text-decoration:underline;color:rgb(17,85,204)"><a class="gmail-in-cell-link" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1416723" target="_blank">Bug 1416723</a></span>)</li></ul><div><b>Threading Overhead</b></div><div><ul><li>Kris added measurements for thread stacks across platforms (<span id="gmail-field-value-dependson"></span><a id="gmail-this-bug" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1475899">Bug 1475899</a>, <a id="gmail-this-bug" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1476405">Bug 1476405</a>, <a id="gmail-this-bug" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1477512">Bug 1477512)</a></li><li>Kris reduced memory usage on Linux by <b>~3MB</b> (that's megabytes!) by changing our default stack size (<a id="gmail-this-bug" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1476828">Bug 1476828</a>)</li><li><b>Eric Rahm</b> (this author) reduced memory usage by <b>50KB</b> by reducing the amount of networking threads (<a id="gmail-this-bug" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1448034">Bug 1448034</a>)</li><li><b>Xidorn Quan</b> committed an upstream Rust patch (<a href="https://github.com/rust-lang/rust/issues/52847">rust-lang/rust#52847</a>) to fix how stack sizes are set on windows after Kris' initial investigation (<a id="gmail-this-bug" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1479250">Bug 1479250</a>) <br></li></ul></div><div><b>Font Overhead</b></div><div><ul><li>The winner of biggest improvement with the smallest change goes to <b>Lee Salzman</b> who reduced memory usage on OSX by <b>10MB</b> by reducing the skia glyph cache (<a id="gmail-this-bug" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1258781">Bug 1258781</a>)<br></li></ul></div></div><div><b>Lessons learned</b></div><div><br></div><div>Small fixes add up, removing dead code not only helps code quality but can save memory, adding measurements is important, caches can be easy targets. If you know of a cache we might tweak please file a bug to consider reducing it.</div><div><br></div><div>-e<br></div><div><br></div><div>[1] <a href="https://treeherder.mozilla.org/perf.html#/graphs?timerange=2592000&series=autoland,1684872,1,4">https://treeherder.mozilla.org/perf.html#/graphs?timerange=2592000&series=autoland,1684872,1,4</a></div><div>[2] <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1476432">https://bugzilla.mozilla.org/show_bug.cgi?id=1476432</a></div><div>[3] <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1470591">https://bugzilla.mozilla.org/show_bug.cgi?id=1470591</a></div><div>[4] <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=648417">https://bugzilla.mozilla.org/show_bug.cgi?id=648417</a><br></div></div>