Repository navigation
[JSC] A VM with a sampling profiler builds the PC to CodeOrigin maps that the profiler reads #804
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
Open
dylan-conway
wants to merge
6
commits into
main
Choose a base branch
from
claude/sampling-profiler-ftl-frame-position
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eaaf126
[JSC] A VM with a sampling profiler builds the PC to CodeOrigin maps …
dylan-conway e6ff130
sampling-profiler-inlined-top-frame.js only asks that the inlined fun…
dylan-conway eb1826c
sampling-profiler-inlined-top-frame.js throws when the samples it wai…
dylan-conway 4e3e70e
The flag for the PC to CodeOrigin maps, which compiler threads read, …
dylan-conway 2584418
sampling-profiler-start-during-ftl-compilation.js makes testLoopCount…
dylan-conway 9027169
Say that the flag for the PC to CodeOrigin maps is only ever turned on
dylan-conway 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,44 @@ | ||
| if (platformSupportsSamplingProfiler()) { | ||
| load("./sampling-profiler/samplingProfiler.js", "caller relative"); | ||
|
|
||
| // Long enough for the call to cost next to nothing beside it, whichever tiers the two functions are in. | ||
| function inner(x) { | ||
| let sum = 0; | ||
| for (let i = 0; i < 1000; i++) | ||
| sum += (x ^ i) * 3; | ||
| return sum; | ||
| } | ||
|
|
||
| function outer(count) { | ||
| let total = 0; | ||
| for (let i = 0; i < count; i++) | ||
| total += inner(i); | ||
| return total; | ||
| } | ||
| noInline(outer); | ||
|
|
||
| // In the top tiers inner() is inlined, and only the PC tells the two apart. What is sampled on the way there does not count. | ||
| for (let i = 0; i < testLoopCount; i++) | ||
| outer(2); | ||
| samplingProfilerStackTraces(); | ||
|
|
||
| const timeToFail = 50000; | ||
| const startTime = Date.now(); | ||
| let innerSamples = 0; | ||
| let outerSamples = 0; | ||
| while (innerSamples + outerSamples < 40) { | ||
| if (Date.now() - startTime > timeToFail) | ||
| throw new Error(`after ${timeToFail} ms inner() has ${innerSamples} samples and outer() has ${outerSamples}`); | ||
| outer(100); | ||
| for (const trace of samplingProfilerStackTraces().traces) { | ||
| const name = trace.frames[0].name; | ||
| if (name === "inner") | ||
| innerSamples++; | ||
| else if (name === "outer") | ||
| outerSamples++; | ||
| } | ||
| } | ||
|
|
||
| if (innerSamples <= outerSamples) | ||
| throw new Error(`inner() has ${innerSamples} samples and outer() has ${outerSamples}`); | ||
| } |
16 changes: 16 additions & 0 deletions
16
JSTests/stress/sampling-profiler-start-during-ftl-compilation.js
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,16 @@ | ||
| //@ runFTLEager | ||
|
|
||
| // Only means something with concurrent compilation and low thresholds. The numbers are what keeps | ||
| // the FTL threads busy at the moment the profiler starts, and the process alive until they are done. | ||
| if (platformSupportsSamplingProfiler()) { | ||
| const functions = []; | ||
| for (let k = 0; k < 300; k++) | ||
| functions.push(new Function("count", `let sum = ${k}; for (let i = 0; i < count; i++) { sum += (i ^ ${k}) * 3; sum = (sum % 1000003) | 0; } return sum;`)); | ||
|
|
||
| for (let round = 0; round < 30; round++) { | ||
| if (round === 8) | ||
| startSamplingProfiler(); | ||
| for (const f of functions) | ||
| f(40); | ||
| } | ||
| } | ||
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.