gecko-dev/xpcom
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
..
base Bug 1358761 - replace PurpleBlock with SegmentedVector to reduce indirect memory accesses when calling suspect, r=mccr8,nfroyd 2017-05-05 00:49:22 +03:00
build 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
components Bug 1351732 - Part 2: Replace use of PLArena with ArenaAllocator in xpcom. r=froydnj 2017-03-30 16:46:58 -07:00
doc
ds Bug 1352889 - Ensure that PLDHashTable's second hash doesn't have padding with 0 bits for tables with capacity larger than 2^16. r=njn 2017-05-04 15:17:50 -07:00
glue Bug 1332639 followup. I apparently didn't actually remove the nsStringAPI.* files, but that was the intention, r=oops 2017-03-02 09:23:08 -05:00
idl-parser Backed out changeset c8fe57b085bd (bug 1333631) 2017-01-30 23:17:34 +01:00
io Backed out 2 changesets (bug 1360992, bug 1361654) for a 70% failure rate in test_fileReader.html on ASan e10s 2017-05-05 12:35:57 -07:00
libxpt/xptcall
reflect Bug 1251198 - Remove various obsolete events from document.createEvent r=smaug 2017-04-20 15:45:37 +03:00
rust Bug 1359353 - Make the backing buffers of XPCOM strings available as mutable slices. r=mystor. 2017-04-25 13:17:48 +03:00
string Bug 1362194 - part 1 - add a fallible CopyASCIItoUTF16 function; r=mccr8 2017-05-05 11:33:36 -04:00
system Bug 1349363 - Centralize pref-checking code for e10s-multi control. r=Felipe 2017-04-17 14:36:04 -07:00
tests Bug 1361601 - Remove nsSystemInfo.getProperty("host") r=froydnj 2017-05-02 16:54:46 -04:00
threads merge mozilla-inbound to mozilla-central a=merge 2017-05-05 15:17:26 +02:00
typelib Bug 1336311 - Change code comments with http://hg.mozilla.org to https://. r=gps 2017-02-07 17:52:56 +01:00
windbgdlg
xpidl
moz.build Bug 1295762 - Part 1: Implement rust bindings to XPCOM's string types, r=froydnj 2016-09-20 11:26:43 -04:00
xpcom-config.h.in Bug 1326145 - Remove HAVE_CPP_AMBIGUITY_RESOLVING_USING. r=froydnj 2016-12-29 18:05:20 +11:00
xpcom-private.h.in