Hi everyone,

It's time for another quick update about the recent Quantum Flow work.

I want to start by shedding some light into the performance of synchronous
IPC caused by JavaScript.  Here is a breakdown report
<https://docs.google.com/spreadsheets/d/1x_BWVlnQPg0DHbsrvPFX7g89lnFGa3lAIHWD_pLa_dE/edit#gid=2125738210&fvid=2071042255>
for data as of today similar to the previous ones.  Let's look at the top
10 worst offenders:

   - All of the ones with names starting with Addons: or Content: are e10s
   compatibility shims that we have been using to make non-e10s compatible
   add-ons work with Firefox.  They essentially make synchronous XPCOM APIs
   work using sync IPC across process boundaries.  This is by far the majority
   of the issue here, and it skews all sorts of performance measurements that
   we do on Nightly.  We're soon
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1352204> going to make
   changes to Nightly <https://wiki.mozilla.org/Add-ons/ShimsNightly> to
   disable running non-e10s compatible extensions so that we get better
   performance data.
   - The second one is AdblockPlus:Message which presumably comes from one
   of the the Adblock Plus extension variants.  What's curious about this one
   is the super high count of the messages, the median time isn't that high.
   And that the submission percentage is 100%!!
   - #9 is contextmenu
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1360406>.

Looking through more of these messages, there are a few more that stem from
our code.  It's a bit hard to spot everything due to everything being mixed
together.  After traditional style extensions aren't loaded any more a lot
of these issues will go away but it also makes things difficult to evaluate
when looking at the data.  This is also solid practical data that can be
used as input to API design in the future, on why some functionality such
as sync IPC is very dangerous to be exposed at the API level in the first
place!  Moving to a more modern extension model is really good for
performance from this perspective.

The next topic I wanted to discuss was the issue of the usage of timers in
our code.  Timers are terrible for responsiveness and are almost never what
you want.  We sometimes use them to lazify some work (do this part of the
initialization in 10 seconds!) or to do some periodic background task
(refresh this cache every second) but they cause a lot of problems due to
the fact that they can execute at unpredictable times.  From the
perspective of improving the responsiveness of Firefox, if your goal is to
keep the main thread as free as possible when the user's input events are
about to be handled, the last thing you want is to start running one of
these timers right before the user clicks or types or something like that.
Gecko now supports the requestIdleCallback API
<https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback>
which allows the caller to request a timer that only gets dispatched when
the application is idle.  Where possible, you should consider re-examining
the timers in your areas of the code and consider using to idle dispatch
where appropriate.  Note that this API is currently only available to
contexts where the Window object is available.  Bug 1358476
<https://bugzilla.mozilla.org/show_bug.cgi?id=1358476> is adding the
functionality to nsThread and hopefully we can expose it to JSMs afterwards
as well.

On to the list of the acknowledgements for the week.  As usual, I hope I'm
not forgetting anyone's names here!

   - Kevin Jones' heroic work on moving session restore to restore tabs
   using lazy-browsers
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1345090> finally landed.
   He tried out a nice idea
   <https://bugzilla.mozilla.org/show_bug.cgi?id=906076#c3> to improve the
   performance of restoring a session as the Virtual Tabs add-on, and then he
   started to take a stab at converting the add-on into a patch for Firefox!
   - Tim Taubert's work as of a few weeks ago around improving the
   performance of the session restore data collection times has heavily paid
   off so far.  This chart
   
<https://health.graphics/quantum/track?metric=FX_SESSION_RESTORE_COLLECT_DATA_MS>
   speaks for itself.
   - Ben Tian used a pref cache instead of reading preferences repeatedly
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1357638>, potentially
   incurring expensive hashtable lookups.
   - Thomas Nguyen did the same for the URLClassifier code
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1353853>.
   - Gijs Kruitbosch prevented reading the full MIME type info from the OS
   just to get the mimetype string for an extension
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1352348>.  The former had
   proved <https://bugzilla.mozilla.org/show_bug.cgi?id=1358369> to be very
   expensive.
   - Dão Gottwald removed the FullZoomUI overhead when closing a window
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1356911>.  He also removed
   an unnecessary layout flush from Window.outerWidth and outerHeight
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1358809>.  This is the Oh
   No! Reflow add-on helping the Web!  :-)
   - Sam Foster removed a synchronous layout flush that used to occur every
   time a window would be activated/deactivated
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1334642>.
   - Olli Pettay tracked down and fixed a memory leak regression caused by
   touch events <https://bugzilla.mozilla.org/show_bug.cgi?id=1357872>
   which would result in many ghost windows, manifesting as long cycle
   collector pauses.  This was a really tricky regression that took a few days
   to track down and it was caused by a simple programming mistake.  Michael
   Layzell is working on a static analysis
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1359455> to ensure that
   this class of memory leaks will never happen, ever again, because we all
   have better things to do with our time than track bugs like this.
   - Jon Coppeard enabled incremental sweeping of foreground JavaScript
   objects <https://bugzilla.mozilla.org/show_bug.cgi?id=1352430>.  These
   are objects with the JSCLASS_FOREGROUND_FINALIZE JSClass flag, the most
   common example includes the JS wrapper objects for WebIDL DOM objects.
   - Marco Bonardo enabled high-res favicons
   <https://bugzilla.mozilla.org/show_bug.cgi?id=977177> and in the process
   won us ~30% improvement on the tp5n nonmain_normal_fileio benchmark
   
<https://treeherder.mozilla.org/perf.html#/graphs?series=%5Bautoland,71d8c9e8252c6fedce43a3523d376e92351c109f,1,1%5D>
   .
   - Tom Schuster enabled caching index values in JS strings
   <https://bugzilla.mozilla.org/show_bug.cgi?id=654190>, to optimize cases
   where JS strings such as "1" are used as an index into an array to speed up
   the string-to-int conversions.
   - Steve Fink fixed a Gecko Profiler specific overhead
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1298816> that would
   inflate the cost of GCs artificially.
   - Nicholas Nethercote fixed capturing startup profiles with the Gecko
   Profiler <https://bugzilla.mozilla.org/show_bug.cgi?id=1356694>.
   - Gerald Squelart removed another sync IPC used early during the startup
   of the content process
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1337062>.
   - Samael Wang reworked tab ID calculation to rely on both processes
   agreeing on a formula rather than sync IPC
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1337064>.
   - Florian Quèze improved the performance of the search engine URL
   generation in the ParamSubstitutions function
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1356593>.  He also removed
   a synchronous layout flush
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1358382> that used to
   happen when opening the searchbar panel for the first time.  He also removed
   the cost of a non-existent notification
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1358173> which apparently
   was taking 8% of _delayedStartup() in a profile.  Last but not
least, he mechanically
   replaced the usage of all (function(args){/*code*/}).bind(this) with the
   faster arrow functions from our chrome JS code
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1355056>.
   - Kris Maglione prevented us from doing a synchronous layout flush when
   computing tab geometry
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1358415>.
   - André Bargull enabled us to syntax-parse destructuring JS patterns
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1303703>.  This
   optimization improves things for us right now for chrome JS code that uses
   the destructuring patterns feature.
   - JW Wang made the channel loading click-to-play media marked as urgent
   priority <https://bugzilla.mozilla.org/show_bug.cgi?id=1348053>.
   - Andrea Marchesini removed some of the Blob related sync IPC messages
   as part of his PBlob refactoring
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1353629>.
   - Mike Conley removed the reader mode promotion panel
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1352501>.  This feature
   would cause a visible UI jank shortly after starting Firefox for the first
   time.
   - Jan de Mooij moved ProxyValueArray inline instead of being dynamically
   allocated <http://ProxyValueArray>.
   - Nicholas Hurley made the work under PredictorLearn() which gets called
   when opening Necko channels happen asynchronously
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1348460>.
   - Chris H-C made several improvements to the INPUT_EVENT_RESPONSE_MS
   probe, most importantly making sure we don't get inflated results when
   the computer comes out of sleep mode
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1357742>.

Until next time, happy hacking!

Cheers,
-- 
Ehsan
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to