Bug 169077 - Disable JavaScript JIT in non-audible background tabs
Summary: Disable JavaScript JIT in non-audible background tabs
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
Keywords: InRadar, Performance
Depends on:
Reported: 2017-03-02 04:42 PST by Andreas Kling
Modified: 2017-04-10 06:20 PDT (History)
15 users (show)

See Also:

Proposed patch (1.72 KB, patch)
2017-03-02 04:42 PST, Andreas Kling
no flags Details | Formatted Diff | Diff
Proposed patch (3.33 KB, patch)
2017-04-06 17:06 PDT, Andreas Kling
fpizlo: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kling 2017-03-02 04:42:09 PST
We already discard all JIT code when coming under memory pressure. We should also stop generating new code until the pressure comes back down, to avoid sawtoothing.
Comment 1 Andreas Kling 2017-03-02 04:42:58 PST
Created attachment 303191 [details]
Proposed patch
Comment 2 Andreas Kling 2017-03-02 13:37:56 PST
Comment on attachment 303191 [details]
Proposed patch

Let's only do this for non-visible tabs as a first cut.
Comment 3 Saam Barati 2017-03-02 15:36:37 PST
Comment 4 Andreas Kling 2017-03-24 10:42:39 PDT
Let's try doing this for processes that are inactive (haven't been foreground active for an hour and are not playing sound)
Comment 5 Andreas Kling 2017-04-06 17:00:46 PDT
Comment 6 Andreas Kling 2017-04-06 17:06:47 PDT
Created attachment 306440 [details]
Proposed patch
Comment 7 Filip Pizlo 2017-04-10 06:14:33 PDT
Comment on attachment 306440 [details]
Proposed patch

I'm not sure any of this is a good idea. 

What if the background tab starts doing computation?  The llint can be 10,000x slower in extreme cases. That's a lot of wasted power. It could even be a spin when you go back to that tab. 

I don't think we want this.
Comment 8 Filip Pizlo 2017-04-10 06:20:12 PDT
What if instead, background tab meant that the thresholds for hiring are scaled higher?  Could be 3x higher or something. That would ensure that in my scenario, the hot code will tier up and not waste as much power. 

But even this feels somehow wrong. The JIT thresholds are the way that they are because we think that they will make the code run faster and use less power. If some code causes us to instead waste power by JITing too much, then maybe our thresholds are wrong for all kinds of tabs.

Can you provide context for why you think this is good?