-
Notifications
You must be signed in to change notification settings - Fork 245
feat(swingset-runner): Add cpu/heap profiling support #11400
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
base: master
Are you sure you want to change the base?
Conversation
Deploying agoric-sdk with
|
Latest commit: |
a9a16ed
|
Status: | ✅ Deploy successful! |
Preview URL: | https://317675e4.agoric-sdk.pages.dev |
Branch Preview URL: | https://usman-swingset-runner-profil.agoric-sdk.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable, modulo some tweaks to argument processing. Thanks for the type annotations. Do you think you could also add a simple README.md?
packages/swingset-runner/src/main.js
Outdated
@@ -368,6 +377,56 @@ export async function main() { | |||
case '--sbench': | |||
swingsetBenchmarkDriverPath = argv.shift(); | |||
break; | |||
case '--cpu-profile-output': | |||
cpuProfileFilePath = path.resolve(String(argv.shift())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cpuProfileFilePath = path.resolve(String(argv.shift())); | |
cpuProfileFilePath = path.resolve(argv.shift()); |
packages/swingset-runner/src/main.js
Outdated
case '--cpu-profile-output': | ||
cpuProfileFilePath = path.resolve(String(argv.shift())); | ||
await new Promise(resolve => { | ||
const parentDirectory = path.dirname(String(cpuProfileFilePath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const parentDirectory = path.dirname(String(cpuProfileFilePath)); | |
const parentDirectory = path.dirname(cpuProfileFilePath); |
packages/swingset-runner/src/main.js
Outdated
const parentDirectory = path.dirname(String(cpuProfileFilePath)); | ||
fs.access(parentDirectory, fs.constants.F_OK, err => { | ||
if (err) { | ||
console.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should throw rather than warn. Also, wouldn't the whole thing be easier with fs/promises?
try {
const parentDirectory = path.dirname(cpuProfileFilePath);
const dir = await fsp.opendir(parentDirectory);
dir.closeSync();
if (!inspectorSession) {
await initializeInspectorSession();
}
} catch (cause) {
throw Error(`Can't record CPU profile at ${cpuProfileFilePath}`, { cause });
}
packages/swingset-runner/src/main.js
Outdated
case '--heap-sampling-interval': | ||
samplingInterval = Number(argv.shift()); | ||
if (Number.isNaN(samplingInterval) || samplingInterval < 1) | ||
console.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please throw
instead.
config.devices.bridge = { | ||
sourceSpec: bridge.srcPath, | ||
}; | ||
config.devices.bridge = { sourceSpec: bridge.srcPath }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man, I'd love to see this reimplemented on the cosmic-swingset test kit too!
I have added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not render well; the line breaks are all collapsed.
@@ -303,7 +303,8 @@ export async function main() { | |||
logStats = true; | |||
break; | |||
case '--logtag': | |||
logTag = argv.shift(); | |||
nextArg = argv.shift(); | |||
nextArg && (logTag = nextArg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If --logtag ''
, is invalid, it should be rejected with an error rather than silently ignored.
@@ -333,11 +334,13 @@ export async function main() { | |||
doDumps = true; | |||
break; | |||
case '--dumpdir': | |||
dumpDir = argv.shift(); | |||
nextArg = argv.shift(); | |||
nextArg && (dumpDir = nextArg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise here.
doDumps = true; | ||
break; | ||
case '--dumptag': | ||
dumpTag = argv.shift(); | ||
nextArg = argv.shift(); | ||
nextArg && (dumpTag = nextArg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
Description
This PR adds support for generating cpu and/or heap profiles in the swingset runner using the engine's native inspector
Also fixed some typing errors (not all of them)
Security Considerations
None
Scaling Considerations
None
Documentation Considerations
Added help messages for the added flags
Testing Considerations
Tested by generating profiles
Upgrade Considerations
None