Commit Graph

46 Commits

Author SHA1 Message Date
Kris Maglione
a723c8955d Bug 1366511: Part 3 - Add mozilla::ToResult() to convert other result types to equivalent Result. r=nbp,ehsan
Also adds a mozilla/ResultExtensions.h header to define the appropriate
conversion functions for nsresult and PRResult. This is in a separate header
since those types are not available in Spidermonkey, and this is the pattern
other *Extensions.h headers follow.

Also removes equivalent NS_TRY macros and WrapNSResult inlines that served the
same purpose in existing code, and are no longer necessary.

MozReview-Commit-ID: A85PCAeyWhx
2017-08-29 21:28:31 -07:00
Kris Maglione
b3bfcf48cf Bug 1366511: Part 2 - Allow autoconverting Err(nsresult) to nsresult. r=ehsan,nbp
This allows MOZ_TRY and MOZ_TRY_VAR to be transparently used in XPCOM methods
when compatible Result types are used.

Also removes a compatibility macro in SimpleChannel.cpp, and an identical
specialization in AddonManagerStartup, which are no longer necessary after
this change.

MozReview-Commit-ID: 94iNrPDJEnN
2017-08-29 21:28:22 -07:00
Masatoshi Kimura
e40c1c203e Bug 1390106 - Stop using versioned scripts in js/xpconnect. r=mccr8
MozReview-Commit-ID: LP7bXQd7ahD
2017-08-14 20:45:14 +09:00
Kris Maglione
50ec68b449 Bug 1385822 - Don't save new scripts from child process after cache flush. r=erahm
MozReview-Commit-ID: GKInmHvwVMP
2017-07-31 14:30:51 -07:00
Kris Maglione
0c502cfbd7 Bug 1382329: Part 4 - Hold mMonitor while accessing scripts in the write thread. r=erahm
MozReview-Commit-ID: 66se8G27sqQ
2017-07-19 14:16:56 -07:00
Kris Maglione
1233d7ac3c Bug 1382329: Part 3 - Wait for pending parse tasks to finish before freeing scripts. r=erahm,nbp
Off-thread parse tasks depend on the memory allocated by the main-thread
script preloader, so that memory needs to be kept alive until they finish. In
normal use cases, this is guaranteed, but when the browser shuts down very
quickly (as sometimes happens in tests), or we invalidate the startup caches
in the middle of the startup process, they can sometimes be freed too early.

MozReview-Commit-ID: GQmkVbWgTH9
2017-07-25 15:23:12 -07:00
Kris Maglione
36fa0f80a2 Bug 1382329: Part 2 - Eagerly encode scripts for the startup cache. r=erahm,nbp
MozReview-Commit-ID: JqCqQZ2rO2z
2017-07-19 12:44:17 -07:00
Kris Maglione
8daf78cc41 Bug 1382329: Part 1 - Enable lazy source whenever compiling for the preloader. r=mccr8,nbp
In general, we always want to compile with lazy source whenever we intend to
store code in the startup bytecode cache. Currently, we only do so when the
main StartupCache is available (which is only in the parent process), even if
we'll be storing code in the ScriptPreloader cache.

The main side-effect of this is that scripts which are used in a content
process do not use lazy source, but *do* use lazy parsing. And since we need
to clone pre-loaded scripts into their target compartment before executing, we
end up eagerly compiling those lazy functions on the main thread as soon as we
execute the script, in order to clone them. And this causes two side-effects
of its own:

1) It's terrible for startup performance.

2) It creates new scope chains which didn't exist when the clone began, and
which are likely responsible for bug 1367896.

MozReview-Commit-ID: 6lZLb68zitp
2017-07-19 11:57:18 -07:00
Andrea Marchesini
9e8ae1dfd0 Bug 1350958 - Finish labeling ProxyReleaseEvent, r=billm 2017-07-14 08:49:22 +02:00
Kris Maglione
da152a5785 Bug 1371248: Avoid hangs when preloader cache flush is triggered during shutdown. r=erahm
MozReview-Commit-ID: FpW53d5TTCG
2017-06-28 14:46:30 -07:00
Bill McCloskey
ce42826bdf Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
2017-06-26 14:19:58 -07:00
Carsten "Tomcat" Book
238bf154d5 Backed out changeset 4f6302a98ae4 (bug 1372405) 2017-06-21 13:59:26 +02:00
Bill McCloskey
67e8af4720 Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
2017-06-20 21:44:11 -07:00
Carsten "Tomcat" Book
bbe9441993 Backed out changeset 9846de3bd954 (bug 1372405) 2017-06-20 08:27:02 +02:00
Bill McCloskey
f69608368b Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
2017-06-19 22:25:47 -07:00
Bevis Tseng
e6dc9e02bc Bug 1372453 - Part 2: Name the caller of ProxyReleaseEvent. r=billm
MozReview-Commit-ID: LYhSWnZkq0i
2017-06-14 09:27:17 +08:00
Kris Maglione
25d1a96b30 Bug 1364974: Part 5 - Perform off-thread decode operations in chunks, rather than singly. r=shu
MozReview-Commit-ID: DapDuQ8rdTI
2017-05-16 19:42:12 -07:00
Kris Maglione
db12e89b0a Bug 1364974: Part 4 - Replace CachedScript::mStatus and related logic with original and final process sets. r=erahm
The current logic is fairly hard to follow, and fails to account for changes
in the set of processes a script needs to be executed in when deciding whether
to write a new cache file. These changes simplify that logic considerably,
increase the chances that we'll correctly pre-decode a script that's needed in
a given process during startup.

MozReview-Commit-ID: BvqjKU8FDHW
2017-05-22 23:01:39 -07:00
Kris Maglione
2453436c47 Bug 1364934: Ignore cached scripts from content processes which were removed in a cache flush. r=erahm
MozReview-Commit-ID: AnmsM3WiZMX
2017-05-17 22:55:14 -07:00
Kris Maglione
b6a58b1b7e Bug 1361900: Part 11 - Make sure new cache file is closed before renaming on Windows. r=me
MozReview-Commit-ID: KpJpId6eULt
2017-05-13 22:55:34 -07:00
Kris Maglione
a2c34c33d2 Bug 1361900: Part 10 - Replace linked lists with a single hashtable. r=erahm
MozReview-Commit-ID: 3qXnswsP6Z0
2017-05-13 22:43:08 -07:00
Kris Maglione
74171bab99 Bug 1361900: Part 9 - Sort scripts by initial load time before saving. r=erahm
MozReview-Commit-ID: 54UN2DVK4xM
2017-05-13 14:08:42 -07:00
Kris Maglione
9b1f5930f3 Bug 1361900: Part 6 - Add content process support for the script preloader. r=erahm,gabor
MozReview-Commit-ID: 6hDQAI52bKC
2017-05-02 17:17:52 -07:00
Kris Maglione
97dff8870c Bug 1361900: Part 4 - Use a separate script cache for scripts loaded in the child process. r=erahm,gabor
MozReview-Commit-ID: EIdwmuTOl90
2017-05-09 19:52:17 -07:00
Kris Maglione
3a4147c0fb Bug 1361900: Part 2 - Add process types field to cached script data. r=erahm
MozReview-Commit-ID: Gvh672XD0ar
2017-05-03 17:21:31 -07:00
Sebastian Hengst
e04a511297 Backed out changeset 39ffa8a7801a (bug 1361900) 2017-05-13 18:53:50 +02:00
Sebastian Hengst
21c66afcab Backed out changeset ad243db647c7 (bug 1361900) 2017-05-13 18:53:40 +02:00
Sebastian Hengst
a3b74893c8 Backed out changeset 4227bcda00ba (bug 1361900) 2017-05-13 18:53:30 +02:00
Sebastian Hengst
b9af39bbfa Backed out changeset 2a48f8b743d1 (bug 1361900) 2017-05-13 18:53:15 +02:00
Sebastian Hengst
47a0097791 Backed out changeset 75b28187fa5e (bug 1361900) 2017-05-13 18:53:10 +02:00
Sebastian Hengst
1411620009 Backed out changeset 0b38ac21c7a5 (bug 1361900) 2017-05-13 18:52:25 +02:00
Sebastian Hengst
0545c7ee8d Backed out changeset 23dc7b443bb0 (bug 1361900) 2017-05-13 18:51:57 +02:00
Kris Maglione
5ed1d1edcb Bug 1361900: Fix one last merge botch, and fix a false rooting hazard warning.
MozReview-Commit-ID: JpKYYEBpbQj
2017-05-12 18:14:12 -07:00
Kris Maglione
15e363d2b3 Bug 1361900: Follow-up: Fix order of execution issue. r=me
MozReview-Commit-ID: DcmTlzxskUj
2017-05-12 15:46:34 -07:00
Kris Maglione
c9956d2c0a Bug 1361900: Part 10 - Replace linked lists with a single hashtable. r=erahm
MozReview-Commit-ID: 3qXnswsP6Z0
2017-05-03 16:57:31 -07:00
Kris Maglione
df8e7cf669 Bug 1361900: Part 9 - Sort scripts by initial load time before saving. r=erahm
MozReview-Commit-ID: 54UN2DVK4xM
2017-05-01 14:12:01 -07:00
Kris Maglione
50a722a8d7 Bug 1361900: Part 6 - Add content process support for the script preloader. r=erahm,gabor
MozReview-Commit-ID: 6hDQAI52bKC
2017-05-02 17:17:52 -07:00
Kris Maglione
12df64d482 Bug 1361900: Part 4 - Use a separate script cache for scripts loaded in the child process. r=erahm,gabor
MozReview-Commit-ID: EIdwmuTOl90
2017-05-09 19:52:17 -07:00
Kris Maglione
94d84195be Bug 1361900: Part 2 - Add process types field to cached script data. r=erahm
MozReview-Commit-ID: Gvh672XD0ar
2017-05-03 17:21:31 -07:00
Kris Maglione
5395bd04d5 Bug 1359653: Follow-up: Don't cache mochikit scripts as a temporary bustage workaround.
MozReview-Commit-ID: I4FcZWRKlWr
2017-05-06 14:41:22 -07:00
Kris Maglione
dd0b06b87f Bug 1359653: Part 9 - Observe "startupcache-invalidate" and flush the cache when received. r=erahm
Flushing the cache at startup is already handled automatically by the
AppStartup code, which removes the entire startupCache directory when
necessary. The add-on manager requires being able to flush the cache at
runtime, though, for the sake of updating bootstrapped add-ons.

MozReview-Commit-ID: LIdiNHrXYXu
2017-05-03 12:31:51 -07:00
Kris Maglione
cc1348b222 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
2017-05-06 12:24:22 -07:00
Sebastian Hengst
393e7b6bbc Backed out changeset 1c7df9455059 (bug 1359653) 2017-05-06 11:02:23 +02:00
Sebastian Hengst
53028b71e4 Backed out changeset 8f4637881ddc (bug 1359653) 2017-05-06 11:02:04 +02:00
Kris Maglione
881111c21d Bug 1359653: Part 9 - Observe "startupcache-invalidate" and flush the cache when received. r=erahm
Flushing the cache at startup is already handled automatically by the
AppStartup code, which removes the entire startupCache directory when
necessary. The add-on manager requires being able to flush the cache at
runtime, though, for the sake of updating bootstrapped add-ons.

MozReview-Commit-ID: LIdiNHrXYXu
2017-05-03 12:31:51 -07:00
Kris Maglione
ab738f1b0b 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
2017-05-05 16:15:04 -07:00