Last active
June 25, 2019 17:41
-
-
Save hotsphink/62adfdac38c0fab3f25dc6f82b4f5999 to your computer and use it in GitHub Desktop.
mkgist-created gist
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
#!/usr/bin/perl | |
use Getopt::Long; | |
use strict; | |
my %score; | |
my $prename; | |
my $postname; | |
GetOptions("pre|0=s" => \$prename, | |
"post|1=s" => \$postname, | |
"help|h!" => \&usage); | |
sub usage { | |
print <<"END"; | |
$0 --pre=<pre> --post=<post> results.txt | |
where <pre> and <post> are labels embedded in results.txt, which has the format | |
name=SomeLabel | |
SomeScore: 83242 | |
AnotherScore: 8311 | |
name=AnotherLabel | |
SomeScore: 63213 | |
AnotherScore: 7311 | |
If --pre (aka -0) and/or --post (aka -1) are not passed, they'll be guessed | |
from the order of the results.txt file. | |
END | |
exit(1); | |
} | |
my @names; | |
my $which; | |
while(<>) { | |
if (/name=(.*)/) { | |
$which = $1; | |
push @names, $1; | |
} elsif (/^Iteration (\d+)\s+([\d.]+)/) { | |
$score{$which}{$1} = $2; | |
} elsif (/^(\w+)[^:]*: (\d+)/) { | |
$score{$which}{$1} = $2; | |
} | |
} | |
$prename ||= shift(@names); | |
die "$prename not found" if ! exists $score{$prename}; | |
$score{pre} = $score{$prename}; | |
$postname ||= shift(@names); | |
die "$postname not found" if ! exists $score{$postname}; | |
$score{post} = $score{$postname}; | |
my $maxlen = 0; | |
foreach (keys %{ $score{pre} }) { | |
$maxlen = length if length > $maxlen; | |
} | |
sub compare { | |
return int($a) ? $a <=> $b : $a cmp $b; | |
} | |
print "$prename -> $postname\n"; | |
print "\n"; | |
foreach (sort compare keys %{ $score{pre} }) { | |
my ($pre, $post) = ($score{post}{$_}, $score{pre}{$_}); | |
my $delta = -($post - $pre); | |
printf("% ${maxlen}s: %6.0f -> %6.0f = %+6.0f (%+5.1f%%)\n", | |
$_, $post, $pre, $delta, 100 * $delta / $post); | |
} |
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
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
my %seen; | |
my %hits; | |
my %misses; | |
# my $N = 40; | |
my $N = 10; | |
while(<>) { | |
chomp; | |
if (/^([LD]) (\d+) (.*)/) { | |
my ($charset, $len, $str) = ($1, $2, $3); | |
next if $len > $N; | |
if (($seen{$charset}{$len} || '~Jfd?IDJf') eq $str) { | |
$hits{$charset}{$len}++; | |
} else { | |
$misses{$charset}{$len}++; | |
} | |
$seen{$charset}{$len} = $str; | |
} | |
} | |
my ($total_hits, $total_misses) = (0, 0); | |
for my $charset (qw(L D)) { | |
for my $len (sort { $a <=> $b } keys %{ $seen{$charset} }) { | |
my $hits = $hits{$charset}{$len} || 0; | |
my $misses = $misses{$charset}{$len} || 0; | |
$total_hits += $hits; | |
$total_misses += $misses; | |
my $eliminated = $hits / ($hits + $misses); | |
printf("%s % 2d % 6d hits, % 6d misses eliminating %.1f%%\n", | |
$charset, $len, $hits, $misses, $eliminated * 100); | |
} | |
} | |
my $hits = $total_hits; | |
my $misses = $total_misses; | |
my $eliminated = $hits / ($hits + $misses); | |
printf("total %d hits, %d misses eliminating %.1f%% of %d\n", | |
$hits, $misses, $eliminated * 100, $hits + $misses); |
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
#!/bin/bash | |
# Run requested tests, collect GC timings, summarize. | |
# | |
# Example usage: ./octane.run -t run-pdfjs.js on off | |
# | |
# This will run the run-pdfjs.js script (which only runs the pdfjs subtest) | |
# with nursery strings on and off. Each configuration will be run 5 times. | |
# Default: run all tests | |
TEST=run.js | |
#TEST=fixed-splay.js | |
#TEST=run-pdfjs.js | |
SRCDIR=/home/sfink/src/mozilla2 | |
# Pass `-t scriptname.js` to run a different set. | |
if [[ $1 = -t ]]; then | |
shift | |
TEST="$1" | |
shift | |
fi | |
# Paths to JS shells to test. The actual use of these variables will be in the | |
# test_* function below. Change these to point to wherever you put your | |
# (optimized!) JS shell objdirs. | |
BIN0=$SRCDIR/bin-inbound/dist/bin/js | |
BIN1=$SRCDIR/obj-js-opt/dist/bin/js | |
#BIN_prejit=$SRCDIR/bin-prejit/dist/bin/js | |
BIN_prejit=$SRCDIR/bin-prejit-trace/dist/bin/js | |
#BIN_jit=$SRCDIR/bin-jit/dist/bin/js | |
cd $SRCDIR/js/src/octane | |
[ -d results ] || mkdir results | |
run_id=$(ls results | wc -l) | |
logdir=results/run${run_id} | |
mkdir "$logdir" | |
function run () { | |
local bin="$1" | |
local log="$2" | |
local size="$3" | |
echo "[[ ${size}MB nursery $log ]]" | |
echo "" | |
MOZ_GCTIMER=$log $bin --nursery-size=$size $TEST 2>&1 | tee ${log%.gc}.log | fgrep -v MinorGC: | egrep '^\w+( \(.*\))?:' | tee ${log%.gc}.txt | |
perl octane.pl $log | tee -a ${log%.gc}.txt | |
echo "" | |
} | |
function runperf () { | |
local bin="$1" | |
local log="$2" | |
local size="$3" | |
echo "[[ ${size}MB nursery $log ]]" | |
echo "" | |
MOZ_GCTIMER=$log perf record -o ${log%.gc}.data $bin --nursery-size=$size fixed-splay.js | egrep '^\w+( \(.*\))?:' | tee ${log%.gc}.txt | |
perl octane.pl $log | tee -a ${log%.gc}.txt | |
echo "" | |
} | |
function test_nursery_sizes () { | |
for i in $(seq 5); do | |
for size in 1 16; do | |
run $BIN0 $logdir/inbound.${size}MB.${i}.gc $size | |
run $BIN1 $logdir/nursery.${size}MB.${i}.gc $size | |
done | |
done | |
} | |
function test_enabled () { | |
for e in on off; do | |
for i in $(seq 5); do | |
if [ $e = off ]; then | |
export MOZ_DISABLE_NURSERY_STRINGS=1 | |
fi | |
run $BIN0 $logdir/inbound.$e.$i.gc 16 | |
run $BIN1 $logdir/nursery.$e.$i.gc 16 | |
unset MOZ_DISABLE_NURSERY_STRINGS | |
done | |
done | |
} | |
function test_disabled () { | |
for e in off; do | |
for i in $(seq 5); do | |
if [ $e = off ]; then | |
export MOZ_DISABLE_NURSERY_STRINGS=1 | |
fi | |
run $BIN0 $logdir/inbound.$e.$i.gc 16 | |
run $BIN1 $logdir/nursery.$e.$i.gc 16 | |
unset MOZ_DISABLE_NURSERY_STRINGS | |
done | |
done | |
} | |
function test_prejit () { | |
export JS_GC_PROFILE_NURSERY=100 | |
for e in off; do | |
for i in $(seq 5); do | |
if [ $e = off ]; then | |
export MOZ_DISABLE_NURSERY_STRINGS=1 | |
fi | |
run $BIN0 $logdir/inbound.$e.$i.gc 16 | |
run $BIN_prejit $logdir/prejit.$e.$i.gc 16 | |
run $BIN1 $logdir/jit.$e.$i.gc 16 | |
unset MOZ_DISABLE_NURSERY_STRINGS | |
done | |
done | |
} | |
function test_prejit_perf () { | |
#export JS_GC_PROFILE_NURSERY=100 | |
for e in off; do | |
for i in $(seq 5); do | |
if [ $e = off ]; then | |
export MOZ_DISABLE_NURSERY_STRINGS=1 | |
fi | |
runperf $BIN_prejit $logdir/prejit.$e.$i.gc 16 | |
runperf $BIN1 $logdir/jit.$e.$i.gc 16 | |
unset MOZ_DISABLE_NURSERY_STRINGS | |
done | |
done | |
} | |
function test_nurstrings () { | |
export JS_GC_PROFILE_NURSERY=100 | |
for e in "$@"; do | |
for i in $(seq 5); do | |
if [ $e = off ]; then | |
export MOZ_DISABLE_NURSERY_STRINGS=1 | |
fi | |
# bin-inbound/ | |
run $BIN0 $logdir/inbound.$e.$i.gc 16 | |
# obj-js-opt/ | |
run $BIN1 $logdir/jit.$e.$i.gc 16 | |
unset MOZ_DISABLE_NURSERY_STRINGS | |
done | |
done | |
} | |
MODES="on" | |
if [ $# -gt 0 ]; then | |
MODES=($*) | |
shift | |
fi | |
export JSGC_DISABLE_POISONING=1 | |
#test_nurstrings on off | |
test_nurstrings ${MODES[@]} | |
# for t in run-*.js; do t=${t#run-}; t=${t%.js}; JS_GC_PROFILE_NURSERY=100 ~/src/mozilla2/obj-js-opt/dist/bin/js run-$t.js > $t.log 2>/dev/null; perl duplicates.pl $t.log; done | tee dupes.txt | |
# useless for most | |
# code-load - very good short strings, good for long but not many long, total 14% | |
# earley-boyer - 82% of only 162 | |
# gbemu - 37% of 14582 all in length 3 | |
# pdfjs - 6% of 94698 all length 2 | |
# regexp - 13% of 80k, spread out, 9.3% 10 or less | |
# typescript - 39% of 197k, spread out but same percent for 10 or less |
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
Tools for looking at octane scores |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment