Repository navigation
[JSC] CodeBlock aging: let idle FTL code (and counter-less DFG code) age out once the mutator goes quiet #557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
58c64e8
[JSC] Let idle FTL code age out: optimizing code with no execution co…
Jarred-Sumner 884b98e
Review: keep the lease's allocation snapshot in its own wrap-safe uin…
Jarred-Sumner 7bac231
Keep sizeof(CodeBlock) <= 224 on Windows: byte-type the 2-bit capabil…
Jarred-Sumner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //@ skip if !$isFTLPlatform | ||
| //@ runDefault("--useEagerCodeBlockJettisonTiming=1", "--useConcurrentJIT=0", "--optimizedCodeAgingQuietAllocationMB=0", "--optimizedCodeAgingQuietSeconds=0.02") | ||
|
|
||
| // With optimizedCodeAgingQuietAllocationMB=0, FTL code never ages out (the previous behaviour), even across two | ||
| // collections further apart than optimizedCodeAgingQuietSeconds with nothing allocated in between. | ||
|
|
||
| function shouldBe(actual, expected, msg) { | ||
| if (actual !== expected) | ||
| throw new Error((msg || "") + " expected " + expected + " but got " + actual); | ||
| } | ||
|
|
||
| var f = new Function("o", "var s = 0; for (var i = 0; i < 8; i++) s += o.a + o.b * i; return [s, isFinalTier()];"); | ||
| var o = { a: 1, b: 2 }, reached = false; | ||
| for (var i = 0; i < 1e6 && !reached; i++) | ||
| reached = f(o)[1]; | ||
| if (!reached) | ||
| throw new Error("test needs f to reach FTL"); | ||
| fullGC(); | ||
| var start = preciseTime(); | ||
| while (preciseTime() - start < 0.04) { } | ||
| fullGC(); | ||
| shouldBe(f(o)[1], true, "with the option off an FTL block never ages out;"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| //@ skip if !$isFTLPlatform | ||
| //@ runDefault("--useEagerCodeBlockJettisonTiming=1", "--useConcurrentJIT=0", "--optimizedCodeAgingQuietSeconds=0.02") | ||
|
|
||
| // FTL code has no execution counter of its own, so it ages against the mutator as a whole | ||
| // (Options::optimizedCodeAgingQuietAllocationMB): once past its TTL it is jettisoned by a full | ||
| // collection that finds (almost) nothing was allocated since the previous one looked at it, and | ||
| // kept - together with the baseline code it pins - whenever the mutator has been allocating. | ||
|
|
||
| function shouldBe(actual, expected, msg) { | ||
| if (actual !== expected) | ||
| throw new Error((msg || "") + " expected " + expected + " but got " + actual); | ||
| } | ||
|
|
||
| function makeHot() { | ||
| return new Function("o", "var s = 0; for (var i = 0; i < 8; i++) s += o.a + o.b * i; return [s, isFinalTier()];"); | ||
| } | ||
|
|
||
| function warmToFTL(f) { | ||
| var o = { a: 1, b: 2 }; | ||
| for (var i = 0; i < 1e6; i++) { | ||
| if (f(o)[1]) | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| function idleFor(seconds) { | ||
| var start = preciseTime(); | ||
| while (preciseTime() - start < seconds) { } | ||
| } | ||
|
|
||
| function allocateMB(n) { | ||
| var keep = []; | ||
| for (var i = 0; i < n * 16; i++) | ||
| keep.push(new Float64Array(8192)); // 64 KB each | ||
| return keep.length; | ||
| } | ||
|
|
||
| // optimizedCodeAgingQuietSeconds above; leave some slack for ApproximateTime. | ||
| var quiet = 0.04; | ||
| var o = { a: 1, b: 2 }; | ||
|
|
||
| // 1. Nothing is allocated between two full collections a TTL apart: the FTL block goes. | ||
| var f = makeHot(); | ||
| if (!warmToFTL(f)) | ||
| throw new Error("test needs f to reach FTL"); | ||
| fullGC(); // records the allocation total for f's FTL block | ||
| idleFor(quiet); | ||
| fullGC(); // nothing allocated since, past TTL: aged out | ||
| shouldBe(f(o)[1], false, "an FTL block should age out across an idle stretch;"); | ||
| shouldBe(f(o)[0], 64, "and the function should still work;"); | ||
|
|
||
| // 2. The mutator allocates between the collections: the block stays, however old. | ||
| var g = makeHot(); | ||
| if (!warmToFTL(g)) | ||
| throw new Error("test needs g to reach FTL"); | ||
| fullGC(); | ||
| for (var round = 0; round < 3; round++) { | ||
| idleFor(quiet); | ||
| allocateMB(4); | ||
| fullGC(); | ||
| shouldBe(g(o)[1], true, "an FTL block should survive while the mutator is allocating (round " + round + ");"); | ||
| } | ||
|
|
||
| // 3. And once the mutator goes quiet it goes too. | ||
| idleFor(quiet); | ||
| fullGC(); | ||
| idleFor(quiet); | ||
| fullGC(); | ||
| shouldBe(g(o)[1], false, "the FTL block should age out once the mutator goes quiet;"); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.