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

WIP Spike Test harden perf on XS #3105

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions packages/xsnap/harden-perf-node/data.readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
turing-node-data.json was captured on my local linux box named 'turing',
whose /proc/cpuinfo says:

model name : Intel(R) Xeon(R) CPU E3-1230L v3 @ 1.80GHz

by running './drive-node-perf.sh > data.json' and then lightly editing
data.json to add [] and remove a trailing comma.

-Brian Warner, 18-may-2021
10 changes: 10 additions & 0 deletions packages/xsnap/harden-perf-node/drive-node-perf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

for name in nothing list hardList listHard; do
for branding in BOTH POSITIVE NEGATIVE; do
# 'listHard' is the most time consuming, 10000 takes 90s
for count in 10 100 1000 10000; do
node -r esm ./t-node-perf.js $branding $name $count |grep -v "Removing"
done
done
done
49 changes: 49 additions & 0 deletions packages/xsnap/harden-perf-node/t-node-perf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { branding, name, count } from './t-setup.js';
import { performance } from 'perf_hooks';

function f(count, body, post) {
const before = performance.now();
let list = {};
for (let i = 0; i < count; i++) {
if (body === '//nothing') {
//nothing
} else if (body === 'list = {next: list};') {
list = {next: list};
} else if (body === 'list = harden({next: list});') {
list = harden({next: list});
} else {
throw Error(`unknown body '${body}'`);
}
}
if (post === '//nothing') {
// nothing
} else if (post === 'harden(list);') {
harden(list);
} else {
throw Error(`unknown post '${post}'`);
}
const after = performance.now();
return(after - before);
}

const [body, post] = {
nothing: ['//nothing', '//nothing'],
list: ['list = {next: list};', '//nothing'],
listHard: ['list = harden({next: list});', '//nothing'],
hardList: ['list = {next: list};', 'harden(list);'],
}[name];

const title = `time, ${branding}, ${count}, ${name}`;
try {
const innerTime = f(count, body, post);
const record = {
branding,
count,
name,
innerTime,
};
console.log(JSON.stringify(record, undefined, ' '), '\n,\n');
} catch (e) {
console.log(`error`, e);
process.exit(1);
}
9 changes: 9 additions & 0 deletions packages/xsnap/harden-perf-node/t-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'ses';

const argv = process.argv.splice(2);
const [branding, name, count_s] = argv;
const count = Number(count_s);
globalThis.HARDEN_BRANDING = branding;
lockdown({});

export { branding, name, count };
Loading