Skip to content

Commit

Permalink
feat: further minor perf instrumentation tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
FUDCo committed Sep 12, 2020
1 parent c5021b3 commit 8e93cd0
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 33 deletions.
16 changes: 8 additions & 8 deletions packages/swingset-runner/demo/megaPong/vat-alice.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ const log = console.log;

// Ping Print Predicate, a hack to reduce log spam
function ppp(count) {
if (count > 10000) {
return count % 10000 === 0;
} else if (count > 1000) {
return count % 1000 === 0;
} else if (count > 100) {
return count % 100 === 0;
} else if (count > 10) {
return count % 10 === 0;
if (count > 9999) {
return count % 9999 === 0;
} else if (count > 999) {
return count % 999 === 0;
} else if (count > 99) {
return count % 99 === 0;
} else if (count > 9) {
return count % 9 === 0;
} else {
return true;
}
Expand Down
16 changes: 8 additions & 8 deletions packages/swingset-runner/demo/megaPong/vat-bob.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ const log = console.log;

// Ping Print Predicate, a hack to reduce log spam
function ppp(count) {
if (count > 10000) {
return count % 10000 === 0;
} else if (count > 1000) {
return count % 1000 === 0;
} else if (count > 100) {
return count % 100 === 0;
} else if (count > 10) {
return count % 10 === 0;
if (count > 9999) {
return count % 9999 === 0;
} else if (count > 999) {
return count % 999 === 0;
} else if (count > 99) {
return count % 99 === 0;
} else if (count > 9) {
return count % 9 === 0;
} else {
return true;
}
Expand Down
16 changes: 16 additions & 0 deletions packages/swingset-runner/polywhacker
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

reference='=> alice contact for bob receives ping: 1 hey!'
success=0
failure=0

while [ 1 ]; do
result=`./whacker`
if [ "$result" == "$reference" ]; then
((success=success+1))
echo "ok (success: $success failure: $failure)"
else
((failure=failure+1))
echo "bad (success: $success failure: $failure)"
fi
done
24 changes: 9 additions & 15 deletions packages/swingset-runner/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export async function main() {
if (logTimes || logMem || logDisk) {
let headers = ['block', 'steps'];
if (logTimes) {
headers.push('btime');
headers.push('btime', 'ctime');
}
if (logMem) {
headers = headers.concat(['rss', 'heapTotal', 'heapUsed', 'external']);
Expand Down Expand Up @@ -529,6 +529,7 @@ export async function main() {
log(`===> end of crank ${crankNumber}`);
}
}
const commitStartTime = readClock();
if (doCommit) {
store.commit();
}
Expand All @@ -541,6 +542,7 @@ export async function main() {
let data = [blockNumber, actualSteps];
if (logTimes) {
data.push(blockEndTime - blockStartTime);
data.push(blockEndTime - commitStartTime);
}
if (logMem) {
const mem = process.memoryUsage();
Expand Down Expand Up @@ -609,21 +611,13 @@ export async function main() {
bootstrapResult = null;
}
}
if (logTimes) {
if (totalSteps) {
const per = deltaT / BigInt(totalSteps);
log(
`runner finished ${totalSteps} cranks in ${deltaT} ns (${per}/crank)`,
);
} else {
log(`runner finished replay in ${deltaT} ns`);
}
if (totalSteps) {
const per = deltaT / BigInt(totalSteps);
log(
`runner finished ${totalSteps} cranks in ${deltaT} ns (${per}/crank)`,
);
} else {
if (totalSteps) {
log(`runner finished ${totalSteps} cranks`);
} else {
log(`runner finished replay`);
}
log(`runner finished replay in ${deltaT} ns`);
}
}
}
4 changes: 2 additions & 2 deletions packages/swingset-runner/trun
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ function runone {
cmdargs="$cmdargs --dump --dumptag t${runct}-"
fi
cmdline="$cmd $cmdargs $@"
echo "$cmdline"
echo "$cmdline > rlog-${runct}"
if [ $dotime ]; then
time $cmdline > rlog-${runct}
(time $cmdline) >& rlog-${runct}
else
$cmdline > rlog-${runct}
fi
Expand Down
12 changes: 12 additions & 0 deletions packages/swingset-runner/whacker
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

t=`jot -p 3 -r 1 3 15`
#echo killing after ${t} secs
bin/runner --init --blockmode run demo/megapong 10000 > /dev/null &
pid=$!
sleep ${t}
kill -9 ${pid} >& /dev/null
wait ${pid} >& /dev/null
sleep 1
#echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
bin/runner --blockmode run demo/megapong 10000 | grep 'alice contact' | tail -1

0 comments on commit 8e93cd0

Please sign in to comment.