Skip to content

Instantly share code, notes, and snippets.

@terrelln
Created March 24, 2020 01:53
Show Gist options
  • Save terrelln/9889fc06a423fd5ca6e99351564473f4 to your computer and use it in GitHub Desktop.
Save terrelln/9889fc06a423fd5ca6e99351564473f4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
set -e
# Use this script to check if your platform has instability.
# Set ENWIK8 to the data you want to test. It doesn't necessarily
# have to be enwik8, any data should have the same results, but that
# is what I used. If you don't have it on your machine, just use another
# largeish file. Set COMPILERS to the compilers you want to test.
# It is good if the DSB cycles are always high and the MITE cycles are
# always low. You have performance instability if the cycles in DSB drop
# and the MITE cycles spike.
# The NICKSERV - BAD example is a case where the performance tanks.
# The NICKSERV - GOOD example is a case where the performance recovered.
# The NICKSERV - BEST example is when it is aligned at a 32+16 byte boundary.
# The DEVBIG - GOOD example is what every commit on the devbig looks like.
# You can see that the MITE cycles are 6x lower than even the best case on
# NICKSERV.
# NICKSERV - BAD
# Performance counter stats for './zstd -tq enwik8.zst' (20 runs):
#
# 461,827,836 cycles:u ( +- 0.03% )
# 1,301,501,797 instructions:u # 2.82 insn per cycle ( +- 0.00% )
# 67,331,424 idq.all_dsb_cycles_any_uops:u ( +- 0.01% )
# 317,781,401 idq.all_mite_cycles_any_uops:u ( +- 0.01% )
# # 0.1343907 +- 0.0000485 seconds time elapsed ( +- 0.04% )
# NICKSERV - GOOD
# Performance counter stats for './zstd -tq enwik8.zst' (20 runs):
#
# 424,731,705 cycles:u ( +- 0.03% )
# 1,301,501,794 instructions:u # 3.06 insn per cycle ( +- 0.00% )
# 141,993,967 idq.all_dsb_cycles_any_uops:u ( +- 0.00% )
# 192,747,913 idq.all_mite_cycles_any_uops:u ( +- 0.00% )
#
# 0.1240921 +- 0.0000395 seconds time elapsed ( +- 0.03% )
# NICKSERV - BEST
# Performance counter stats for './zstd -tq enwik8.zst' (20 runs):
#
# 423,652,867 cycles:u ( +- 0.06% )
# 1,301,504,853 instructions:u # 3.07 insn per cycle ( +- 0.00% )
# 226,354,088 idq.all_dsb_cycles_any_uops:u ( +- 0.01% )
# 65,011,239 idq.all_mite_cycles_any_uops:u ( +- 0.05% )
#
# 0.123488 +- 0.000150 seconds time elapsed ( +- 0.12% )
# DEVBIG - GOOD
# Performance counter stats for './zstd -t enwik8.zst -q' (20 runs):
#
# 514,909,270 cycles ( +- 0.23% ) (24.79%)
# 1,311,267,666 instructions # 2.55 insn per cycle ( +- 0.20% ) (24.61%)
# 332,762,384 idq.all_dsb_cycles_any_uops ( +- 0.19% ) (25.07%)
# 10,045,638 idq.all_mite_cycles_any_uops ( +- 1.28% ) (24.96%)
# 253,960,156 idq.all_dsb_cycles_4_uops ( +- 0.17% ) (24.78%)
#
# 0.17291 +- 0.00102 seconds time elapsed ( +- 0.59% )
ENWIK8=/path/to/test/file
COMPILERS=(gcc)
zstd $ENWIK8 --no-compress-literals -qfo test.zst
for compiler in gcc; do
for commit in 10f915f0 bc0e10ae c9ce6db b7b9d3; do
git checkout $commit 2> /dev/null > /dev/null
CC="$compiler" make clean zstd ZSTD_LEGACY_SUPPORT=0 2> /dev/null > /dev/null
echo -e "\n\n$compiler - $commit\n"
$compiler --version
perf stat -r20 -e cycles,instructions,idq.all_dsb_cycles_any_uops,idq.all_mite_cycles_any_uops -- ./zstd -tq test.zst 2>&1
done
done
# Print the output of lscpu
lscpu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment