Skip to content

Instantly share code, notes, and snippets.

@aclements aclements/pacer.py
Last active Jul 21, 2017

Embed
What would you like to do?
Plot gcpacertrace log
# Read gcpacertrace log from stdin and plot pacing.
import sys
import subprocess
gp = subprocess.Popen(["gnuplot", "-persist", "-e", """
set xrange [0:2];
set yrange [0:1];
set xlabel "Heap ratio (h)";
set ylabel "GC CPU (u_a)";
set cblabel "GC cycle";
set arrow 1 from 1,0 to 1,1 nohead ls 0;
load "viridis.pal";
plot "-" with p palette pt 2 title "actual pacing", 0.25/x title "stable trigger" lc 0 lw 2, 0.25 title "goal" ls 0
"""], stdin=subprocess.PIPE).stdin
# Stable trigger:
# 0 = h_g - h_T - u_a / u_g * (h_a - h_T)
# u_a / u_g * (h_a - h_T) = h_g - h_T
# (h_a - h_T) / (h_g - h_T) = u_g / u_a
# h = u_g / u_a
i = 0
for line in sys.stdin:
if not line.startswith("pacer: H"):
continue
v = {}
for part in line.strip().split()[1:]:
k, val = part.split("=")
v[k] = float(val)
print >> gp, (v["h_a"] - v["h_t"]) / (v["h_g"] - v["h_t"]), v["u_a"], i
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.