gecko-dev/xpcom/build
Kris Maglione 15e7adf3aa Bug 1359653: Part 5 - Pre-load scripts needed during startup in a background thread. r=shu,erahm
One of the things that I've noticed in profiling startup overhead is that,
even with the startup cache, we spend about 130ms just loading and decoding
scripts from the startup cache on my machine.

I think we should be able to do better than that by doing some of that work in
the background for scripts that we know we'll need during startup. With this
change, we seem to consistently save about 3-5% on non-e10s startup overhead
on talos. But there's a lot of room for tuning, and I think we get some
considerable improvement with a few ongoing tweeks.

Some notes about the approach:

- Setting up the off-thread compile is fairly expensive, since we need to
create a global object, and a lot of its built-in prototype objects for each
compile. So in order for there to be a performance improvement for OMT
compiles, the script has to be pretty large. Right now, the tipping point
seems to be about 20K.

  There's currently no easy way to improve the per-compile setup overhead, but
we should be able to combine the off-thread compiles for multiple smaller
scripts into a single operation without any additional per-script overhead.

- The time we spend setting up scripts for OMT compile is almost entirely
CPU-bound. That means that we have a chunk of about 20-50ms where we can
safely schedule thread-safe IO work during early startup, so if we schedule
some of our current synchronous IO operations on background threads during the
script cache setup, we basically get them for free, and can probably increase
the number of scripts we compile in the background.

- I went with an uncompressed mmap of the raw XDR data for a storage format.
That currently occupies about 5MB of disk space. Gzipped, it's ~1.2MB, so
compressing it might save some startup disk IO, but keeping it uncompressed
simplifies a lot of the OMT and even main thread decoding process, but, more
importantly:

- We currently don't use the startup cache in content processes, for a variety
of reasons. However, with this approach, I think we can safely store the
cached script data from a content process before we load any untrusted code
into it, and then share mmapped startup cache data between all content
processes. That should speed up content process startup *a lot*, and very
likely save memory, too. And:

- If we're especially concerned about saving per-process memory, and we keep
the cache data mapped for the lifetime of the JS runtime, I think that with
some effort we can probably share the static string data from scripts between
content processes, without any copying. Right now, it looks like for the main
process, there's about 1.5MB of string-ish data in the XDR dumps. It's
probably less for content processes, but if we could save .5MB per process
this way, it might make it easier to increase the number of content processes
we allow.

MozReview-Commit-ID: CVJahyNktKB

--HG--
extra : source : 1c7df945505930d2d86a076ee20807104324c8cc
extra : histedit_source : 75e193839edf727874f01b2a9f6852f6c1f087fb%2C3ce966d7dcf2bd0454a7d673d0467097456bd782
2017-05-06 12:24:22 -07:00
..
BinaryPath.h Bug 1332639 - Fix nsBrowserApp.cpp and related headers to compile without the external string API, r=glandium 2017-02-27 13:39:34 -05:00
FileLocation.cpp Bug 1338086 - Remove useless else blocks in order to reduce complexity in xpcom/ r=froydnj 2017-02-09 15:31:35 +01:00
FileLocation.h
IOInterposer.cpp Bug 1298676 - part 1 - add IOInterposer::Enable(); r=aklotz 2017-01-10 16:31:25 -05:00
IOInterposer.h Bug 1298676 - part 2 - add an AutoIOInterposerDisable RAII class; r=aklotz 2017-01-10 16:31:25 -05:00
IOInterposerPrivate.h
LateWriteChecks.cpp Bug 1341023 - Take module name encoding into account for late writes and hangs. r=Dexter 2017-02-21 22:44:42 +00:00
LateWriteChecks.h
MainThreadIOLogger.cpp Bug 1024669 - Part 1: Annotate crash reports with thread names. r=gsvelto 2017-02-07 18:57:23 +08:00
MainThreadIOLogger.h
NSPRInterposer.cpp Bug 1317954 - Use C++11's override and remove virtual where applicable in xpcom/. r=froydnj 2016-11-16 14:27:07 +02:00
NSPRInterposer.h
Omnijar.cpp
Omnijar.h
PoisonIOInterposer.h
PoisonIOInterposerBase.cpp Bug 1312087 - part 1 - move mozilla::{Mutex,CondVar} to use mozglue locking primitives; r=erahm 2017-03-21 10:20:36 -05:00
PoisonIOInterposerMac.cpp
PoisonIOInterposerStub.cpp
PoisonIOInterposerWin.cpp
ServiceList.h Bug 527003 - separating XPCOM parts from nsAccessibilityService. Removing a11y service in favour of using nsAccessibilityService directly. Adding support for a11y service shutdown. r=surkov 2016-08-08 20:51:39 -04:00
Services.cpp Bug 1336086 - remove mozilla::services::_external_Get*Service; r=bsmedberg,jesup 2017-02-03 11:52:02 -05:00
Services.h Bug 1336086 - remove mozilla::services::_external_Get*Service; r=bsmedberg,jesup 2017-02-03 11:52:02 -05:00
TlsAllocationTracker.cpp Bug 1320134 - Part 1: Tracking TLS allocations for diagnosing out-of-TLS-slots crashes on Windows. r=froydnj 2017-03-15 18:20:30 +08:00
TlsAllocationTracker.h Bug 1320134 - Part 1: Tracking TLS allocations for diagnosing out-of-TLS-slots crashes on Windows. r=froydnj 2017-03-15 18:20:30 +08:00
XPCOM.h Bug 1315812 - Mark nsISupportsArray, nsICollection, nsIEnumerator as deprecated. r=froydnj 2016-11-10 13:15:33 -08:00
XPCOMInit.cpp Bug 1359653: Part 5 - Pre-load scripts needed during startup in a background thread. r=shu,erahm 2017-05-06 12:24:22 -07:00
XPCOMModule.inc Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm) 2017-01-26 16:35:54 -08:00
XREAppData.h Bug 1284897 - Add mechanism to libsandbox_s to track names of files that have been given special sandbox access permissions (PermissionsService). r=bobowen, r=glandium 2017-02-14 15:08:40 -08:00
XREChildData.h Bug 1332530 - Move GMPLoader code out of plugin-container and back into XUL. r=gerald 2017-01-19 15:39:03 +13:00
XREShellData.h
mach_override.c
mach_override.h
moz.build Bug 1351732 - Part 2: Replace use of PLArena with ArenaAllocator in xpcom. r=froydnj 2017-03-30 16:46:58 -07:00
nsWindowsDllInterceptor.h Bug 1349444: Teach the disassembler about "cmp byte ptr [relative], imm8". r=handyman 2017-05-03 17:11:59 -04:00
nsXPCOM.h Bug 1331820 - Disallow NS_ConvertUTF16toUTF8 for NS_NewNativeLocalFile. r=froydnj 2017-01-21 15:48:56 +09:00
nsXPCOMCID.h Bug 1329718 - remove nsISupportsVoid and associated machinery; r=erahm 2017-01-10 16:31:48 -05:00
nsXPCOMCIDInternal.h
nsXPCOMPrivate.h Bug 1306327 - Remove everything related to frozen functions from the XPCOM glue. r=bsmedberg 2017-01-10 17:12:43 +09:00
nsXULAppAPI.h Bug 1343075 - Use GeckoEditableSupport from PuppetWidget; r=masayuki r=rbarker r=snorp r=esawin 2017-03-07 22:34:39 -05:00
perfprobe.cpp
perfprobe.h
xpcom_alpha.def
xrecore.h Bug 1306329 - Stop exporting XPCOM and XUL symbols. r=glandium 2016-12-02 12:55:34 -05:00