Last Comment Bug 836177 - Temporarily merge JSMs part 2: electric boogaloo
: Temporarily merge JSMs part 2: electric boogaloo
Product: Firefox Health Report
Classification: Client Software
Component: Client: Desktop (show other bugs)
: unspecified
: x86 Mac OS X
-- normal
: Firefox 21
Assigned To: Gregory Szorc [:gps] (away until 2017-03-20)
Depends on: 834936
Blocks: 836285 831397 838461
  Show dependency treegraph
Reported: 2013-01-29 20:18 PST by Gregory Szorc [:gps] (away until 2017-03-20)
Modified: 2013-04-08 08:35 PDT (History)
6 users (show)
See Also:
QA Whiteboard:
Iteration: ---
Points: ---

Merge more JSMs, v1 (7.94 KB, patch)
2013-01-29 20:18 PST, Gregory Szorc [:gps] (away until 2017-03-20)
rnewman: review+
Details | Diff | Splinter Review

Description User image Gregory Szorc [:gps] (away until 2017-03-20) 2013-01-29 20:18:08 PST
Created attachment 707985 [details] [diff] [review]
Merge more JSMs, v1

Merge moar JSMs because of compartment clownshoes.


async.js - 81k
observers.js - 93k
rest.js - 106k


datareporting - 205 -> 236 (31)
healthreport - 462 -> 533 (71)

Net: 178kb saved.

After this patch, FHR loads the following JSMs that aren't in one of the two main compartments:

* Sqlite.jsm
* Task.jsm
* services-common/utils.js
* services-common/preferences.js
* services-common/log4moz.js

Sqlite.jsm and Task.jsm aren't worth merging IMO (more users and not in /services).

log4moz.js and utils.js are loaded by Sqlite.jsm. So, we'd have to hack up Sqlite.jsm. I believe this is out of the question.

log4moz.js has some singletons and having an instance in multiple compartments might make things act weird.

preferences.js is loaded by both of FHR's main compartments. We probably could load it in both without any issue. But, I think it's easier to not merge.

As rnewman stated in the previous bug, this merging does scare me to some degree. I'm not overly worried (I trust our tests). But, it's extremely hacky and I want to see it gone immediately.

All told, FHR is hovering around 1.4MB with this patch applied. That counts log4moz (176), prefs (133), utils (131), and sqlite (147) (which are shared among multiple features). SQLite is likely the only feature that is always running, so it takes the hit for increasing memory. We are around 740k for the 2 main compartments and 80k for the SQLite connection.

In bug 836120, I freed about ~628kb of memory from Sync when Sync isn't configured by not loading modules. However, some of those modules are also used by FHR (like utils and log4moz). So, the net gain isn't as high as I would like. Still, Sync's code is better and we do still gain a little more from making Sync behave better.
Comment 1 User image Richard Newman [:rnewman] 2013-01-29 23:15:12 PST
Comment on attachment 707985 [details] [diff] [review]
Merge more JSMs, v1

Review of attachment 707985 [details] [diff] [review]:

Task.jsm is 72 non-comment lines of simple code; I don't think it falls in the same bucket as Sqlite.jsm.

I wholeheartedly support preprocessing that into the mix, too, and seeing what the outcome is. If it's a net win, do it.
Comment 2 User image Gregory Szorc [:gps] (away until 2017-03-20) 2013-01-30 07:28:42 PST
Comment 3 User image Gregory Szorc [:gps] (away until 2017-03-20) 2013-01-30 16:15:47 PST

Note You need to log in before you can comment on or make changes to this bug.