Skip to content
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

feat: add a command to download the Hermes Sampling Profiler to a local machine #1246

Merged
merged 68 commits into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
1167db0
added adb commands
jessieAnhNguyen Jul 7, 2020
2047721
feat: implemented download hermes profile command
jessieAnhNguyen Jul 21, 2020
4af2cbe
deleted unused adbkit packages
jessieAnhNguyen Jul 22, 2020
98e1ecf
changed files excluded node modules
jessieAnhNguyen Jul 22, 2020
24a248b
handled edge case when there's no file
jessieAnhNguyen Jul 22, 2020
b720baf
deleted unnecessary changes
jessieAnhNguyen Jul 22, 2020
4c0fb45
deleted unnecessary changes 2
jessieAnhNguyen Jul 22, 2020
defc7b7
Merge pull request #2 from MLH-Fellowship/jessie
jessieAnhNguyen Jul 27, 2020
b5d1d3c
added transformer files
jessieAnhNguyen Jul 28, 2020
89837ae
implemented --verbose flag
jessieAnhNguyen Jul 28, 2020
23cd80c
Merge branch 'jessie-cli2' into test/transformer
jessieAnhNguyen Jul 28, 2020
3e7c6f4
integrated transformer tool with CLI
jessieAnhNguyen Jul 28, 2020
cbc0c28
implemented --raw flag
jessieAnhNguyen Jul 28, 2020
28a55d4
deleted changelog comments and fixed small changes
jessieAnhNguyen Jul 30, 2020
680eccb
changed wording
jessieAnhNguyen Jul 30, 2020
ef6bb10
deleted unused event types and remove unused dev dependencies
jessieAnhNguyen Jul 30, 2020
2285b38
generated source map through
jessieAnhNguyen Aug 6, 2020
86c8110
Merge pull request #4 from MLH-Fellowship/test/transformer
jessieAnhNguyen Aug 10, 2020
652290d
fixed SHA-1 error
jessieAnhNguyen Aug 10, 2020
deffdd2
Merge branch 'master' of https://github.com/MLH-Fellowship/cli into f…
jessieAnhNguyen Aug 10, 2020
f560481
implemented the source map steps
jessieAnhNguyen Aug 10, 2020
e3fe062
added transformer package and profile-hermes.md
jessieAnhNguyen Aug 11, 2020
1cff3c8
Merge pull request #6 from MLH-Fellowship/feat/generate-source-map
jevakallio Aug 11, 2020
ca07916
Rename command to profile-hermes
jessieAnhNguyen Aug 11, 2020
867b6b2
Improve command line output examples
jessieAnhNguyen Aug 11, 2020
7ee8fc6
Extract source map functionality to its own file
jessieAnhNguyen Aug 11, 2020
4e0dd95
Readability improvements (@todo: fix @TODO comments)
jessieAnhNguyen Aug 11, 2020
c422253
upgrade hermes-profile-transformer package
jessieAnhNguyen Aug 11, 2020
3d9d04e
implemented @TODO: remove axios and use node-fetch
jessieAnhNguyen Aug 13, 2020
29e55ca
deleted small unintended changes and removed axios
jessieAnhNguyen Aug 13, 2020
1078bdb
removed axios package and deleted unnecessary changes
jessieAnhNguyen Aug 13, 2020
e050ab2
removed source-map related packages
jessieAnhNguyen Aug 13, 2020
b955db9
added new line after each logger
jessieAnhNguyen Aug 13, 2020
e086ec9
Merge pull request #7 from MLH-Fellowship/chore/pre-publish
jessieAnhNguyen Aug 13, 2020
423424f
Merge branch 'master' of https://github.com/MLH-Fellowship/cli
jessieAnhNguyen Aug 13, 2020
b37a804
upgraded hermes-profile-transformer package to latest
jessieAnhNguyen Aug 14, 2020
2f93778
moved profile-hermes folder out of cli to a separate package cli-hermes
jessieAnhNguyen Aug 18, 2020
ed90c7e
deleted the command from projectCommands in cli
jessieAnhNguyen Aug 18, 2020
aacd874
re-added the command in the projectCommands
saphal1998 Aug 18, 2020
86cba71
removed unused dependencies from cli
saphal1998 Aug 18, 2020
48b1b0f
added cli-hermes to the list of yarn link
jessieAnhNguyen Aug 18, 2020
e53ee19
Merge pull request #9 from MLH-Fellowship/movePackage
jessieAnhNguyen Aug 18, 2020
e3ff688
removed unused @types/ip dependency
jessieAnhNguyen Aug 18, 2020
f5e51e1
Merge remote-tracking branch 'upstream/master'
jessieAnhNguyen Aug 18, 2020
a0ad665
added @types/ip dependency in cli-hermes
jessieAnhNguyen Aug 18, 2020
1735396
moved @types/ip to dev dependency
jessieAnhNguyen Aug 18, 2020
1b0438b
added type definition for cli-hermes
saphal1998 Aug 18, 2020
5ebb4ba
fixed type definition
jessieAnhNguyen Aug 18, 2020
236b038
Added cli-hermes ref to tsconfig in packages/cli
saphal1998 Aug 18, 2020
8da90e5
Merge branch 'master' of github.com:MLH-Fellowship/cli
saphal1998 Aug 18, 2020
f7cb658
Removed unnecessary code comment
jessieAnhNguyen Aug 19, 2020
c85506e
made changes based on PR review
jessieAnhNguyen Aug 19, 2020
125836c
Merge branch 'master' of https://github.com/MLH-Fellowship/cli
jessieAnhNguyen Aug 19, 2020
b7dbb5e
added a verbose log
jessieAnhNguyen Aug 19, 2020
27f14d9
added cli-platform-android as a dependency
jessieAnhNguyen Aug 19, 2020
02263ae
added cli-platform-android as a dependency in cli
jessieAnhNguyen Aug 19, 2020
8fc1b01
Fixing path in tsconfig
saphal1998 Aug 19, 2020
bfc08b2
Merge conflict
saphal1998 Aug 19, 2020
4478249
Added type defs of platform-android to cli-hermes, path fixed
saphal1998 Aug 19, 2020
93acfcd
Fixed chalk version on cli-hermes
saphal1998 Aug 19, 2020
9607160
removed unnecessary comment
jessieAnhNguyen Aug 21, 2020
4e50329
Merge remote-tracking branch 'upstream/master'
jessieAnhNguyen Aug 21, 2020
dcabe01
Merge branch 'master' of https://github.com/MLH-Fellowship/cli
jessieAnhNguyen Aug 21, 2020
3e97a31
changed --filename flag and throw real error
jessieAnhNguyen Sep 1, 2020
f4b4041
Merge pull request #10 from MLH-Fellowship/review/edit
jessieAnhNguyen Sep 1, 2020
75095c5
Fix catch block in profile-hermes/index to match the error thrown
saphal1998 Sep 3, 2020
32a917e
Typecast error as CLIError
saphal1998 Sep 3, 2020
8d6fb8f
Apply suggestions from code review
saphal1998 Sep 4, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@react-native-community/cli-server-api": "^4.10.1",
"@react-native-community/cli-tools": "^4.10.1",
"@react-native-community/cli-types": "^4.10.1",
"@types/source-map": "^0.5.7",
"chalk": "^3.0.0",
"command-exists": "^1.2.8",
"commander": "^2.19.0",
Expand All @@ -59,6 +60,7 @@
"pretty-format": "^25.2.0",
"semver": "^6.3.0",
"serve-static": "^1.13.1",
"source-map": "^0.7.3",
"strip-ansi": "^5.2.0",
"sudo-prompt": "^9.0.0",
"wcwidth": "^1.0.1"
Expand Down
136 changes: 136 additions & 0 deletions packages/cli/src/commands/profile/EventInterfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import {EventsPhase} from './Phases';

export interface SharedEventProperties {
/**
* name of the event
*/
name?: string;
/**
* event category
*/
cat?: string;
/**
* tracing clock timestamp
*/
ts?: number;
/**
* process ID
*/
pid?: number;
/**
* thread ID
*/
tid?: number;
/**
* event type (phase)
*/
ph: EventsPhase;
/**
* id for a stackFrame object
*/
sf?: number;
/**
* thread clock timestamp
*/
tts?: number;
/**
* a fixed color name
*/
cname?: string;
/**
* event arguments
*/
args?: {[key in string]: any};
}

interface DurationEventBegin extends SharedEventProperties {
ph: EventsPhase.DURATION_EVENTS_BEGIN;
}

interface DurationEventEnd extends SharedEventProperties {
ph: EventsPhase.DURATION_EVENTS_END;
}

export type DurationEvent = DurationEventBegin | DurationEventEnd;

export type Event = DurationEvent;

/**
* Each item in the stackFrames object of the hermes profile
*/
export interface HermesStackFrame {
line: string;
column: string;
funcLine: string;
funcColumn: string;
name: string;
category: string;
/**
* A parent function may or may not exist
*/
parent?: number;
}
/**
* Each item in the samples array of the hermes profile
*/
export interface HermesSample {
cpu: string;
name: string;
ts: string;
pid: number;
tid: string;
weight: string;
/**
* Will refer to an element in the stackFrames object of the Hermes Profile
*/
sf: number;
stackFrameData?: HermesStackFrame;
}

/**
* Hermes Profile Interface
*/
export interface HermesCPUProfile {
traceEvents: SharedEventProperties[];
samples: HermesSample[];
stackFrames: {[key in string]: HermesStackFrame};
}

export interface CPUProfileChunk {
id: string;
pid: number;
tid: string;
startTime: number;
nodes: CPUProfileChunkNode[];
samples: number[];
timeDeltas: number[];
}

export interface CPUProfileChunkNode {
id: number;
callFrame: {
line: string;
column: string;
funcLine: string;
funcColumn: string;
name: string;
url?: string;
category: string;
};
parent?: number;
}

export type CPUProfileChunker = {
nodes: CPUProfileChunkNode[];
sampleNumbers: number[];
timeDeltas: number[];
};

export interface SourceMap {
version: string;
sources: string[];
sourceContent: string[];
x_facebook_sources: {names: string[]; mappings: string}[] | null;
names: string[];
mappings: string;
}
30 changes: 30 additions & 0 deletions packages/cli/src/commands/profile/Phases.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export enum EventsPhase {
DURATION_EVENTS_BEGIN = 'B',
DURATION_EVENTS_END = 'E',
COMPLETE_EVENTS = 'X',
INSTANT_EVENTS = 'I',
COUNTER_EVENTS = 'C',
ASYNC_EVENTS_NESTABLE_START = 'b',
ASYNC_EVENTS_NESTABLE_INSTANT = 'n',
ASYNC_EVENTS_NESTABLE_END = 'e',
FLOW_EVENTS_START = 's',
FLOW_EVENTS_STEP = 't',
FLOW_EVENTS_END = 'f',
SAMPLE_EVENTS = 'P',
OBJECT_EVENTS_CREATED = 'N',
OBJECT_EVENTS_SNAPSHOT = 'O',
OBJECT_EVENTS_DESTROYED = 'D',
METADATA_EVENTS = 'M',
MEMORY_DUMP_EVENTS_GLOBAL = 'V',
MEMORY_DUMP_EVENTS_PROCESS = 'v',
MARK_EVENTS = 'R',
CLOCK_SYNC_EVENTS = 'c',
CONTEXT_EVENTS_ENTER = '(',
CONTEXT_EVENTS_LEAVE = ')',
// Deprecated
ASYNC_EVENTS_START = 'S',
ASYNC_EVENTS_STEP_INTO = 'T',
ASYNC_EVENTS_STEP_PAST = 'p',
ASYNC_EVENTS_END = 'F',
LINKED_ID_EVENTS = '=',
}
Loading