Bug 169077

Summary: Disable JavaScript JIT in non-audible background tabs
Product: WebKit Reporter: Andreas Kling <kling>
Component: JavaScriptCoreAssignee: Andreas Kling <kling>
Status: NEW ---    
Severity: Normal CC: barraclough, benjamin, buildbot, cdumez, cmarcelo, commit-queue, dbates, fpizlo, keith_miller, kling, koivisto, mark.lam, msaboff, ossy, saam, webkit-bug-importer
Priority: P2 Keywords: InRadar, Performance
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Proposed patch
none
Proposed patch fpizlo: review-

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
LGTM
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
<rdar://problem/31038556>
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?