-
Notifications
You must be signed in to change notification settings - Fork 301
Basic Java Flight Recorder support #533
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
11 commits
Select commit
Hold shift + click to select a range
0c859e5
Basic Java Flight Recorder support
beatbrot 2f2af16
Minor touchups
beatbrot 4c7c174
Move jfrview to dev dependencies
beatbrot 679c338
Add tests for JFR parsing
beatbrot 940c0d7
Simplify test setup
beatbrot 3ef1895
Fix accidently changes test
beatbrot 65cf0a0
Merge remote-tracking branch 'upstream/main' into java-flight-recorde…
beatbrot 97bce63
Fix typescript checking
beatbrot 93a135b
Update typescript-json-schema
beatbrot 3163010
Apply suggestions from code review
jlfwong 5669fb4
Update snapshots
jlfwong 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Binary file not shown.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| declare global { | ||
| // Mock modern Typescript constructs used in JfrView until we update our Typescript | ||
| interface SymbolConstructor { | ||
| readonly dispose: symbol | ||
| } | ||
| } | ||
|
|
||
| export {} |
1,167 changes: 1,167 additions & 0 deletions
1,167
src/import/__snapshots__/java-flight-recorder.test.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import fs from 'fs' | ||
|
|
||
| // We need to load the wasm binary as file | ||
| // This is different from the production case where we load the binary via `fetch` | ||
| const wasm_module = fs.readFileSync('node_modules/jfrview/jfrview_bg.wasm') | ||
| module.exports = wasm_module | ||
jlfwong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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,5 @@ | ||
| import {checkProfileSnapshot} from '../lib/test-utils' | ||
|
|
||
| test('importFromJfr', async () => { | ||
| await checkProfileSnapshot('./sample/profiles/java-flight-recorder/heavy.jfr') | ||
| }) |
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,46 @@ | ||
| import {FrameInfo, Profile, ProfileGroup, StackListProfileBuilder} from '../lib/profile' | ||
| import init, {Frame, interpret_jfr} from 'jfrview' | ||
| // @ts-ignore | ||
| import wasm_data from 'jfrview/jfrview_bg.wasm' | ||
|
|
||
| export async function importFromJfr(fileName: string, data: ArrayBuffer): Promise<ProfileGroup> { | ||
| await init({module_or_path: wasm_data}) | ||
| const withoutNative = create_profile(data, false) | ||
| const withNative = create_profile(data, true) | ||
|
|
||
| return { | ||
| indexToView: 0, | ||
| name: fileName, | ||
| profiles: [withoutNative, withNative], | ||
| } | ||
| } | ||
|
|
||
| export function isJfrRecording(buffer: ArrayBuffer) { | ||
| const b = buffer.slice(0, 3) | ||
| const bytes = new Uint8Array(b) | ||
| return bytes[0] === 0x46 && bytes[1] === 0x4c && bytes[2] === 0x52 | ||
| } | ||
|
|
||
| function create_profile(data: ArrayBuffer, includeNative: boolean): Profile { | ||
| const result = interpret_jfr(new Uint8Array(data), includeNative) | ||
|
|
||
| const builder = new StackListProfileBuilder(result.length) | ||
| if (includeNative) { | ||
| builder.setName('With native calls') | ||
| } else { | ||
| builder.setName('Without native calls') | ||
| } | ||
|
|
||
| function to_fi(input: Frame): FrameInfo { | ||
| return { | ||
| name: input.name, | ||
| key: input.name, | ||
| } | ||
| } | ||
|
|
||
| for (const sample of result) { | ||
| builder.appendSampleWithWeight(sample.frames.map(to_fi), 1) | ||
| } | ||
|
|
||
| return builder.build() | ||
| } |
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
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.