rrepair, eval: improve fprob plots for algorithms with a lot of transferred data

#! /usr/bin/gnuplot
# USED PARAMS
#	colDefFile -> file with column definitions
#	srcFile1 -> source file 1 path
#	srcFile1_title -> prepend this to titles of lines from srcFile1
#	srcFile2 -> source file 2 path (optional)
#	srcFile2_title -> prepend this to titles of lines from srcFile2 (optional unless srcFile2 given)
#	srcFile3 -> source file 3 path (optional)
#	srcFile3_title -> prepend this to titles of lines from srcFile3 (optional unless srcFile3 given)
#	srcFile4 -> source file 4 path (optional)
#	srcFile4_title -> prepend this to titles of lines from srcFile4 (optional unless srcFile4 given)
#	destDir -> destination path for pdfs
#	regenAccInPercent -> whether to show the regen accuracy in percent instead of absolute values (useful for bloom)
#	absoluteRedundancy -> whether to show the absolute redundancy or a relative one
#	stepSize -> the stepSize parameter used (2 if unset)
#	systemSize -> the number of items being reconciled

set macro

load colDefFile

step_size = exists("stepSize") ? stepSize : 2
plotCount = exists("srcFile4") ? 4 : exists("srcFile3") ? 3 : exists("srcFile2") ? 2 : 1
files = srcFile1 . (plotCount >= 2 ? " " . srcFile2 : "") . (plotCount >= 3 ? " " . srcFile3 : "") . (plotCount >= 4 ? " " . srcFile4 : "")
get_file(i) = (i == 4) ? srcFile4 : (i == 3) ? srcFile3 : (i == 2) ? srcFile2 : srcFile1
get_title(i) = (i == 4) ? srcFile4_title : (i == 3) ? srcFile3_title : (i == 2) ? srcFile2_title : srcFile1_title
if (plotCount == 4) {
  set style line 1 lw 3 lc -1 pt 5 lt 1
  set style line 2 lw 3 lc 1 pt 9 lt 1
  set style line 3 lw 3 lc rgb "#32CD32" pt 7 lt 1
  set style line 4 lw 3 lc 3 pt 4 lt 3
  set style line 101 lw 3 lc -1 pt 0 lt 1
  set style line 102 lw 3 lc 1 pt 0 lt 1
  set style line 103 lw 3 lc rgb "#32CD32" pt 0 lt 1
  set style line 104 lw 3 lc 3 pt 0 lt 1
  plotShift(x, i) = (i == 4) ? (x + 0.6*(0.5*step_size)) : (i == 3) ? (x + 0.2*(0.5*step_size)) : (i == 2) ? (x - 0.2*(0.5*step_size)) : (x - 0.6*(0.5*step_size))
} else {
  set style line 1 lw 3 lc 1 pt 5 lt 1
  set style line 2 lw 3 lc rgb "#32CD32" pt 9 lt 1
  set style line 3 lw 3 lc 3 pt 7 lt 1
  set style line 101 lw 3 lc 1 pt 0 lt 1
  set style line 102 lw 3 lc rgb "#32CD32" pt 0 lt 1
  set style line 103 lw 3 lc 3 pt 0 lt 1
  if (plotCount == 3) {
    plotShift(x, i) = (i == 3) ? (x + 0.55*(0.5*step_size)) : (i == 2) ? (x) : (x - 0.55*(0.5*step_size))
  } else {
    if (plotCount == 2) {
      plotShift(x, i) = (i == 2) ? (x + 0.4*(0.5*step_size)) : (x - 0.4*(0.5*step_size))
    } else {
      plotShift(x, i) = x
    }
  }
}
if (exists("regenAccInPercent") && regenAccInPercent == 1) {
  regenAcc(found, existing) = 100 - 100 * found / existing
  regenAccErr(found1, found2, existingSum) = stderrSum(found1, found2) * (100 / existingSum)
} else {
  regenAccInPercent = 0
  regenAcc(found, existing) = existing - found
  regenAccErr(found1, found2, existingSum) = stderrSum(found1, found2)
}
if (exists("absoluteRedundancy") && absoluteRedundancy == 1) {
  redundancy(transferred, updated, regen) = transferred - (updated + regen)
  redundancyStderr(transferred, updated, regen) = sqrt(transferred**2 - updated**2 - regen**2)
} else {
  absoluteRedundancy = 0
  redundancy(transferred, updated, regen) = transferred / (updated + regen)
  redundancyStderr(transferred, updated, regen) = "-"
}
plot_boxwidth = (0.8 / plotCount)

# OUTPUT
set terminal pdfcairo dashed enhanced font ",15" fontscale 0.5 size 6,4.5
fileEx = "pdf"

system "echo 'PLOT " . files . "'"
system "mkdir -p " .destDir

filename = "file"

# --OPTION
kvvSize0 = 16+4 # key+version size in bytes
kvvSize1 = kvvSize0+10 # key+version+value size in byte

# Helper
stderrSum(x,y) = sqrt(x**2 + y**2)	# sum of std. errors is root of sum of square errors
kB(x) = x / 1024
min(x,y) = (x < y) ? x : y
min3(x,y,z) = min(min(x,y),z)
max(x,y) = (x > y) ? x : y
max3(x,y,z) = max(max(x,y),z)

acc_upd_max=0.5
if (regenAccInPercent == 1) {
  do for [i=1:plotCount] {
    stats "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) u (column(col_missing)+column(col_outdated) - column(col_regen)-column(col_updated)+stderrSum(column(col_sd_regen),column(col_sd_updated))) nooutput
    if (STATS_max > acc_upd_max) {acc_upd_max = STATS_max}
  }
  acc_reg_max=50.5
  acc_reg_min=49.5
  do for [i=1:plotCount] {
    stats "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) u (regenAcc(column(col_regen)+column(col_updated), column(col_missing)+column(col_outdated))+regenAccErr(column(col_sd_regen),column(col_sd_updated),(column(col_missing)+column(col_outdated)))):(regenAcc(column(col_regen)+column(col_updated), column(col_missing)+column(col_outdated))-regenAccErr(column(col_sd_regen),column(col_sd_updated),(column(col_missing)+column(col_outdated)))) nooutput
    if (STATS_min_y < acc_reg_min) {acc_reg_min = STATS_min_y}
    if (STATS_max_x > acc_reg_max) {acc_reg_max = STATS_max_x}
  }
  acc_reg_avg=(acc_reg_max+acc_reg_min)/2.0
  acc_reg_max=max(abs(acc_reg_avg-acc_reg_min), abs(acc_reg_max-acc_reg_avg))
} else {
  do for [i=1:plotCount] {
    stats "<awk '$" . col_ftype . " == \"update\" || $" . col_ftype . " == \"regen\"' " . get_file(i) u (column(col_missing)+column(col_outdated) - column(col_regen)-column(col_updated)+stderrSum(column(col_sd_regen),column(col_sd_updated))) nooutput
    if (STATS_max > acc_upd_max) {acc_upd_max = STATS_max}
  }
  acc_reg_max = acc_upd_max
}
if (acc_upd_max > 0.5) {acc_upd_max=acc_upd_max*1.05}
if (acc_reg_max > 0.5) {acc_reg_max=acc_reg_max*1.05}

red_max=0.5
do for [i=1:plotCount] {
  stats "<awk '$" . col_ftype . " == \"update\" || $" . col_ftype . " == \"regen\"' " . get_file(i) using (redundancy(column(col_bw_rs_kvv), column(col_updated), column(col_regen))+redundancyStderr(column(col_sd_bw_rs_kvv), column(col_sd_updated), column(col_sd_regen))) nooutput
  if (STATS_max > red_max) {red_max = STATS_max}
}
if (red_max > 0.5) {red_max=red_max*1.05}
if (red_max >= 1.5 && red_max < 2) {red_max=2}

bw_max=1
do for [i=1:plotCount] {
  stats "<awk '$" . col_ftype . " == \"update\" || $" . col_ftype . " == \"regen\"' " . get_file(i) using (kB(column(col_bw_rc_size)+column(col_bw_rc2_size)+stderrSum(column(col_sd_bw_rc_size), column(col_sd_bw_rc2_size)))) nooutput
  if (STATS_max > bw_max) {bw_max = STATS_max}
}
if (bw_max > 1) {bw_max=bw_max*1.08}

key_width_fun(i) = min(-0.5, (6-strstrt(get_title(i), "_")) - (strlen(get_title(i)) - strstrt(get_title(i), "_")) * 0.15)
key_width = min(key_width_fun(1),key_width_fun(plotCount))
# print "key_width: ",key_width

# Solid Background
# set object 1 rect from screen 0, 0, 0 to screen 1, 1, 0 behind
# set object 1 rect fc  rgb "white"  fillstyle solid 1.0

# Style
if (plotCount == 1) {
  set style data yerrorlines
} else {
  set style data yerrorbars
}
set xtics 0,step_size,5*step_size
set format x "%g %%"
set grid layerdefault   linetype 0 linewidth 1.000,  linetype 0 linewidth 1.000
set pointsize (plotCount == 4) ? 0.7 : (plotCount == 3) ? 0.8 : 1

set style line 100 lw 3 lc -1 pt 0 lt 1

#--------------------------------- ALL
set xrange [-(0.5*step_size):(5.5*step_size)]
set boxwidth plot_boxwidth relative
set style fill solid 0.75 noborder
set xtics scale 0.1
set ytics scale 0.8
set mxtics 2
set grid noxtics mxtics layerdefault linetype 0 linewidth 1.000,  linetype 0 linewidth 1.000

set o destDir. "all_" .filename. "." .fileEx
set multiplot

all_width_r = 0.545
all_width_l = all_width_r
bw_height_full = 0.700
bw_height = (plotCount > 1) ? (bw_height_full - 0.018) : bw_height_full
red_height = 0.170
red_pos_y = bw_height_full - 0.032
acc_height_full = 0.195
acc_height = (plotCount > 1) ? (acc_height_full - 0.012) : acc_height_full
acc_pos_y = (plotCount > 1) ? (red_pos_y + red_height - 0.006) : (red_pos_y + red_height - 0.02)

# accuracy

set size all_width_l,acc_height
set origin -0.002,acc_pos_y
unset xlabel
set format x ""
set ylabel "|Δ| missed " font ",16"
set yrange [0:acc_upd_max]
if (bw_max > 1000) {
  set format y " %2.1f"
} else {
  set format y "%2.1f"
}
if (plotCount > 1) {
  set key at screen 0.512,(acc_pos_y + 0.001) center center vertical Left reverse opaque enhanced autotitles box maxrows 1 width (key_width+1) samplen 1.75 font ",14" spacing 1.3
} else {
  set key top left horizontal Left reverse opaque enhanced autotitles box maxcols 1 width key_width samplen 1.5 font ",13"
}

plot for [i=1:plotCount] "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(column(col_missing)+column(col_outdated) - column(col_regen)-column(col_updated)):(stderrSum(column(col_sd_regen),column(col_sd_updated))) t get_title(i) ls i

set origin 0.49,acc_pos_y
unset key
unset ylabel
unset ytics
set grid y2tics
if (regenAccInPercent == 1) {
  set y2tics mirror offset 0 scale 0.8
  if (bw_max > 1000) {
    set size (all_width_r + 0.028),acc_height
    set format y2 "%-2.1f_{ }%%"
  } else {
    set size (all_width_r + 0.01),acc_height
    set format y2 "%-2.0f_{ }%%"
  }
  set y2range [(acc_reg_avg-acc_reg_max):(acc_reg_avg+acc_reg_max)]
} else {
  set size all_width_r,acc_height
  set y2tics mirror format "%-1.1f" scale 0.8
  set y2range [0:acc_reg_max]
}

plot for [i=1:plotCount] "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(regenAcc(column(col_regen)+column(col_updated), column(col_missing)+column(col_outdated))):(regenAccErr(column(col_sd_regen),column(col_sd_updated),(column(col_missing)+column(col_outdated)))) axes x1y2 t get_title(i) ls (plotCount > 1 ? i : 2)

set ytics scale 0.8
unset y2tics
set grid noy2tics

# redundancy

set ytics autofreq
set size all_width_l,red_height
set origin -0.002,red_pos_y
if (absoluteRedundancy == 1) {
set ylabel "Red." font ",16" # transferred / updated
} else {
set ylabel "rel. Red." font ",16" # transferred / updated
}
set yrange [0:red_max]
set y2range [0:red_max]
if (bw_max > 1000) {
  set format y " %2.1f"
  set format y2 "%-2.1f "
} else {
  set format y "%2.1f"
  set format y2 "%-2.1f"
}
unset key

plot for [i=1:plotCount] "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(redundancy(column(col_bw_rs_kvv), column(col_updated), column(col_regen))) with boxes t get_title(i) ls i, \
     for [i=1:plotCount] "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(redundancy(column(col_bw_rs_kvv), column(col_updated), column(col_regen))):(redundancyStderr(column(col_sd_bw_rs_kvv), column(col_sd_updated), column(col_sd_regen))) with yerrorbars notitle ls (plotCount > 1 ? (100+i) : 100)

set size all_width_r,red_height
set origin 0.49,red_pos_y
if (plotCount == 1) {
  set key top left horizontal Left reverse opaque enhanced autotitles box maxcols 1 width key_width samplen 1.5 font ",13"
}
unset ylabel
unset ytics
set grid y2tics
set y2tics mirror scale 0.8

plot for [i=1:plotCount] "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(redundancy(column(col_bw_rs_kvv), column(col_updated), column(col_regen))) axes x1y2 with boxes t get_title(i) ls (plotCount > 1 ? i : 2), \
     for [i=1:plotCount] "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(redundancy(column(col_bw_rs_kvv), column(col_updated), column(col_regen))):(redundancyStderr(column(col_sd_bw_rs_kvv), column(col_sd_updated), column(col_sd_regen))) axes x1y2 with yerrorbars notitle ls (plotCount > 1 ? (100+i) : 100)

set ytics scale 0.8
unset y2tics
set grid noy2tics

# bandwidth

set size all_width_l,bw_height
set origin -0.002,0
set xlabel "total δ, update" font ",16"
set xtics 0,step_size,5*step_size format "%g %%" rotate by -30 offset -1,0
set ylabel "RC costs (phase 1+2) in KiB" font ",16"
set yrange [0:bw_max]
set y2range [0:bw_max]
set format y "%3.0f"
set mytics 2
if (plotCount > 1) {
  set key at screen 0.512,(red_pos_y + 0.0065) center center vertical Left reverse opaque enhanced autotitles box maxrows 1 width (key_width+1) samplen 1.75 font ",14" spacing 1.3
} else {
  if (srcFile1_title[1:6] eq "merkle" || (exists("srcFile3_title") && srcFile3_title[1:6] eq "merkle") || (exists("srcFile4_title") && srcFile4_title[1:6] eq "merkle")) {
    set key top left horizontal Left reverse opaque enhanced autotitles box maxcols 1 width key_width samplen 1.5 font ",13"
  } else {
    set key bottom right horizontal Right noreverse opaque enhanced autotitles box maxcols 1 width key_width samplen 1.5 font ",13"
  }
}

LABEL = "⇡naïve approach: ≥" . (systemSize*(128+32)/8/1024) . " KiB"
set obj 10 rect at graph 0.5,0.96 size char (strlen(LABEL)-6), char 1
set obj 10 fillstyle solid noborder front
set label 10 at graph 0.5,0.96 LABEL front center font ",12"

plot for [i=1:plotCount] "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(kB(column(col_bw_rc_size)+column(col_bw_rc2_size))) with boxes notitle ls i fs solid 0.3, \
     for [i=1:plotCount] "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(kB(column(col_bw_rc_size))) with boxes t get_title(i) ls i, \
     for [i=1:plotCount] "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(kB(column(col_bw_rc_size)+column(col_bw_rc2_size))):(kB(stderrSum(column(col_sd_bw_rc_size), column(col_sd_bw_rc2_size)))) with yerrorbars notitle ls (plotCount > 1 ? (100+i) : 100)

set size all_width_r,bw_height
set origin 0.49,0
set xlabel "total δ, regen" font ",16"
unset key
unset ylabel
unset ytics
set grid y2tics
set y2tics mirror format "%-3.0f" scale 0.8
set my2tics 2

plot for [i=1:plotCount] "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(kB(column(col_bw_rc_size)+column(col_bw_rc2_size))) axes x1y2 with boxes notitle ls (plotCount > 1 ? i : 2) fs solid 0.3, \
     for [i=1:plotCount] "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(kB(column(col_bw_rc_size))) axes x1y2 with boxes t get_title(i) ls (plotCount > 1 ? i : 2), \
     for [i=1:plotCount] "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(kB(column(col_bw_rc_size)+column(col_bw_rc2_size))):(kB(stderrSum(column(col_sd_bw_rc_size), column(col_sd_bw_rc2_size)))) axes x1y2 with yerrorbars notitle ls (plotCount > 1 ? (100+i) : 100)

#! /usr/bin/gnuplot
# USED PARAMS
#	colDefFile -> file with column definitions
#	srcFile1 -> source file 1 path
#	srcFile1_title -> prepend this to titles of lines from srcFile1
#	srcFile2 -> source file 2 path (optional)
#	srcFile2_title -> prepend this to titles of lines from srcFile2 (optional unless srcFile2 given)
#	srcFile3 -> source file 3 path (optional)
#	srcFile3_title -> prepend this to titles of lines from srcFile3 (optional unless srcFile3 given)
#	srcFile4 -> source file 4 path (optional)
#	srcFile4_title -> prepend this to titles of lines from srcFile4 (optional unless srcFile4 given)
#	destDir -> destination path for pdfs
#	regenAccInPercent -> whether to show the regen accuracy in percent instead of absolute values (useful for bloom)
#	absoluteRedundancy -> whether to show the absolute redundancy or a relative one
#	stepSize -> the stepSize parameter used (2 if unset)
#	systemSize -> the number of items being reconciled

set macro

load colDefFile

step_size = exists("stepSize") ? stepSize : 2
plotCount = exists("srcFile4") ? 4 : exists("srcFile3") ? 3 : exists("srcFile2") ? 2 : 1
files = srcFile1 . (plotCount >= 2 ? " " . srcFile2 : "") . (plotCount >= 3 ? " " . srcFile3 : "") . (plotCount >= 4 ? " " . srcFile4 : "")
get_file(i) = (i == 4) ? srcFile4 : (i == 3) ? srcFile3 : (i == 2) ? srcFile2 : srcFile1
get_title(i) = (i == 4) ? srcFile4_title : (i == 3) ? srcFile3_title : (i == 2) ? srcFile2_title : srcFile1_title
if (plotCount == 4) {
  set style line 1 lw 3 lc -1 pt 5 lt 1
  set style line 2 lw 3 lc 1 pt 9 lt 1
  set style line 3 lw 3 lc rgb "#32CD32" pt 7 lt 1
  set style line 4 lw 3 lc 3 pt 4 lt 3
  set style line 101 lw 3 lc -1 pt 0 lt 1
  set style line 102 lw 3 lc 1 pt 0 lt 1
  set style line 103 lw 3 lc rgb "#32CD32" pt 0 lt 1
  set style line 104 lw 3 lc 3 pt 0 lt 1
  plotShift(x, i) = (i == 4) ? (x + 0.6*(0.5*step_size)) : (i == 3) ? (x + 0.2*(0.5*step_size)) : (i == 2) ? (x - 0.2*(0.5*step_size)) : (x - 0.6*(0.5*step_size))
} else {
  set style line 1 lw 3 lc 1 pt 5 lt 1
  set style line 2 lw 3 lc rgb "#32CD32" pt 9 lt 1
  set style line 3 lw 3 lc 3 pt 7 lt 1
  set style line 101 lw 3 lc 1 pt 0 lt 1
  set style line 102 lw 3 lc rgb "#32CD32" pt 0 lt 1
  set style line 103 lw 3 lc 3 pt 0 lt 1
  if (plotCount == 3) {
    plotShift(x, i) = (i == 3) ? (x + 0.55*(0.5*step_size)) : (i == 2) ? (x) : (x - 0.55*(0.5*step_size))
  } else {
    if (plotCount == 2) {
      plotShift(x, i) = (i == 2) ? (x + 0.4*(0.5*step_size)) : (x - 0.4*(0.5*step_size))
    } else {
      plotShift(x, i) = x
    }
  }
}
if (exists("regenAccInPercent") && regenAccInPercent == 1) {
  regenAcc(found, existing) = 100 - 100 * found / existing
  regenAccErr(found1, found2, existingSum) = stderrSum(found1, found2) * (100 / existingSum)
} else {
  regenAccInPercent = 0
  regenAcc(found, existing) = existing - found
  regenAccErr(found1, found2, existingSum) = stderrSum(found1, found2)
}
if (exists("absoluteRedundancy") && absoluteRedundancy == 1) {
  redundancy(transferred, updated, regen) = transferred - (updated + regen)
  redundancyStderr(transferred, updated, regen) = sqrt(transferred**2 - updated**2 - regen**2)
} else {
  absoluteRedundancy = 0
  redundancy(transferred, updated, regen) = transferred / (updated + regen)
  redundancyStderr(transferred, updated, regen) = "-"
}
plot_boxwidth = (0.8 / plotCount)

# OUTPUT
set terminal pdfcairo dashed enhanced font ",15" fontscale 0.5 size 6,4.5
fileEx = "pdf"

system "echo 'PLOT " . files . "'"
system "mkdir -p " .destDir

filename = "file"

# --OPTION
kvvSize0 = 16+4 # key+version size in bytes
kvvSize1 = kvvSize0+10 # key+version+value size in byte

# Helper
stderrSum(x,y) = sqrt(x**2 + y**2)	# sum of std. errors is root of sum of square errors
kB(x) = x / 1024
min(x,y) = (x < y) ? x : y
min3(x,y,z) = min(min(x,y),z)
max(x,y) = (x > y) ? x : y
max3(x,y,z) = max(max(x,y),z)

acc_upd_max=0.5
if (regenAccInPercent == 1) {
  do for [i=1:plotCount] {
    stats "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) u (column(col_missing)+column(col_outdated) - column(col_regen)-column(col_updated)+stderrSum(column(col_sd_regen),column(col_sd_updated))) nooutput
    if (STATS_max > acc_upd_max) {acc_upd_max = STATS_max}
  }
  acc_reg_max=50.5
  acc_reg_min=49.5
  do for [i=1:plotCount] {
    stats "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) u (regenAcc(column(col_regen)+column(col_updated), column(col_missing)+column(col_outdated))+regenAccErr(column(col_sd_regen),column(col_sd_updated),(column(col_missing)+column(col_outdated)))):(regenAcc(column(col_regen)+column(col_updated), column(col_missing)+column(col_outdated))-regenAccErr(column(col_sd_regen),column(col_sd_updated),(column(col_missing)+column(col_outdated)))) nooutput
    if (STATS_min_y < acc_reg_min) {acc_reg_min = STATS_min_y}
    if (STATS_max_x > acc_reg_max) {acc_reg_max = STATS_max_x}
  }
  acc_reg_avg=(acc_reg_max+acc_reg_min)/2.0
  acc_reg_max=max(abs(acc_reg_avg-acc_reg_min), abs(acc_reg_max-acc_reg_avg))
} else {
  do for [i=1:plotCount] {
    stats "<awk '$" . col_ftype . " == \"update\" || $" . col_ftype . " == \"regen\"' " . get_file(i) u (column(col_missing)+column(col_outdated) - column(col_regen)-column(col_updated)+stderrSum(column(col_sd_regen),column(col_sd_updated))) nooutput
    if (STATS_max > acc_upd_max) {acc_upd_max = STATS_max}
  }
  acc_reg_max = acc_upd_max
}
if (acc_upd_max > 0.5) {acc_upd_max=acc_upd_max*1.05}
if (acc_reg_max > 0.5) {acc_reg_max=acc_reg_max*1.05}

red_max=0.5
do for [i=1:plotCount] {
  stats "<awk '$" . col_ftype . " == \"update\" || $" . col_ftype . " == \"regen\"' " . get_file(i) using (redundancy(column(col_bw_rs_kvv), column(col_updated), column(col_regen))+redundancyStderr(column(col_sd_bw_rs_kvv), column(col_sd_updated), column(col_sd_regen))) nooutput
  if (STATS_max > red_max) {red_max = STATS_max}
}
if (red_max > 0.5) {red_max=red_max*1.05}
if (red_max >= 1.5 && red_max < 2) {red_max=2}

bw_max=1
do for [i=1:plotCount] {
  stats "<awk '$" . col_ftype . " == \"update\" || $" . col_ftype . " == \"regen\"' " . get_file(i) using (kB(column(col_bw_rc_size)+column(col_bw_rc2_size)+stderrSum(column(col_sd_bw_rc_size), column(col_sd_bw_rc2_size)))) nooutput
  if (STATS_max > bw_max) {bw_max = STATS_max}
}
if (bw_max > 1) {bw_max=bw_max*1.08}

key_width_fun(i) = min(-0.5, (6-strstrt(get_title(i), "_")) - (strlen(get_title(i)) - strstrt(get_title(i), "_")) * 0.15)
key_width = min(key_width_fun(1),key_width_fun(plotCount))
# print "key_width: ",key_width

# Solid Background
# set object 1 rect from screen 0, 0, 0 to screen 1, 1, 0 behind
# set object 1 rect fc  rgb "white"  fillstyle solid 1.0

# Style
if (plotCount == 1) {
  set style data yerrorlines
} else {
  set style data yerrorbars
}
set xtics 0,step_size,5*step_size
set format x "%g %%"
set grid layerdefault   linetype 0 linewidth 1.000,  linetype 0 linewidth 1.000
set pointsize (plotCount == 4) ? 0.7 : (plotCount == 3) ? 0.8 : 1

set style line 100 lw 3 lc -1 pt 0 lt 1

#--------------------------------- ALL
set xrange [-(0.5*step_size):(5.5*step_size)]
set boxwidth plot_boxwidth relative
set style fill solid 0.75 noborder
set xtics scale 0.1
set ytics scale 0.8
set mxtics 2
set grid noxtics mxtics layerdefault linetype 0 linewidth 1.000,  linetype 0 linewidth 1.000

set o destDir. "all_" .filename. "." .fileEx
set multiplot

all_width_r = 0.545
all_width_l = all_width_r
bw_height_full = 0.700
bw_height = (plotCount > 1) ? (bw_height_full - 0.018) : bw_height_full
red_height = 0.170
red_pos_y = bw_height_full - 0.032
acc_height_full = 0.195
acc_height = (plotCount > 1) ? (acc_height_full - 0.012) : acc_height_full
acc_pos_y = (plotCount > 1) ? (red_pos_y + red_height - 0.006) : (red_pos_y + red_height - 0.02)

# accuracy

set size all_width_l,acc_height
set origin -0.002,acc_pos_y
unset xlabel
set format x ""
set ylabel "|Δ| missed " font ",16"
set yrange [0:acc_upd_max]
set format y "%2.1f"
if (plotCount > 1) {
  set key at screen 0.512,(acc_pos_y + 0.001) center center vertical Left reverse opaque enhanced autotitles box maxrows 1 width (key_width+1) samplen 1.75 font ",14" spacing 1.3
} else {
  set key top left horizontal Left reverse opaque enhanced autotitles box maxcols 1 width key_width samplen 1.5 font ",13"
}

plot for [i=1:plotCount] "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(column(col_missing)+column(col_outdated) - column(col_regen)-column(col_updated)):(stderrSum(column(col_sd_regen),column(col_sd_updated))) t get_title(i) ls i

set origin 0.49,acc_pos_y
unset key
unset ylabel
unset ytics
set grid y2tics
if (regenAccInPercent == 1) {
  set size (all_width_r+0.01),acc_height
  set y2tics mirror format "%-2.0f_{ }%%" offset 0 scale 0.8
  set y2range [(acc_reg_avg-acc_reg_max):(acc_reg_avg+acc_reg_max)]
} else {
  set size all_width_r,acc_height
  set y2tics mirror format "%-1.1f" scale 0.8
  set y2range [0:acc_reg_max]
}

plot for [i=1:plotCount] "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(regenAcc(column(col_regen)+column(col_updated), column(col_missing)+column(col_outdated))):(regenAccErr(column(col_sd_regen),column(col_sd_updated),(column(col_missing)+column(col_outdated)))) axes x1y2 t get_title(i) ls (plotCount > 1 ? i : 2)

set ytics scale 0.8
unset y2tics
set grid noy2tics

# redundancy

set ytics autofreq
set size all_width_l,red_height
set origin -0.002,red_pos_y
if (absoluteRedundancy == 1) {
set ylabel "Red." font ",16" # transferred / updated
} else {
set ylabel "rel. Red." font ",16" # transferred / updated
}
set yrange [0:red_max]
set y2range [0:red_max]
set format y "%2.1f"
set format y2 "%-2.1f"
unset key

plot for [i=1:plotCount] "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(redundancy(column(col_bw_rs_kvv), column(col_updated), column(col_regen))) with boxes t get_title(i) ls i, \
     for [i=1:plotCount] "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(redundancy(column(col_bw_rs_kvv), column(col_updated), column(col_regen))):(redundancyStderr(column(col_sd_bw_rs_kvv), column(col_sd_updated), column(col_sd_regen))) with yerrorbars notitle ls (plotCount > 1 ? (100+i) : 100)

set size all_width_r,red_height
set origin 0.49,red_pos_y
if (plotCount == 1) {
  set key top left horizontal Left reverse opaque enhanced autotitles box maxcols 1 width key_width samplen 1.5 font ",13"
}
unset ylabel
unset ytics
set grid y2tics
set y2tics mirror scale 0.8

plot for [i=1:plotCount] "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(redundancy(column(col_bw_rs_kvv), column(col_updated), column(col_regen))) axes x1y2 with boxes t get_title(i) ls (plotCount > 1 ? i : 2), \
     for [i=1:plotCount] "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(redundancy(column(col_bw_rs_kvv), column(col_updated), column(col_regen))):(redundancyStderr(column(col_sd_bw_rs_kvv), column(col_sd_updated), column(col_sd_regen))) axes x1y2 with yerrorbars notitle ls (plotCount > 1 ? (100+i) : 100)

set ytics scale 0.8
unset y2tics
set grid noy2tics

# bandwidth

set size all_width_l,bw_height
set origin -0.002,0
set xlabel "total δ, update" font ",16"
set xtics 0,step_size,5*step_size format "%g %%" rotate by -30 offset -1,0
set ylabel "RC costs (phase 1+2) in KiB" font ",16"
set yrange [0:bw_max]
set y2range [0:bw_max]
set format y "%3.0f"
set mytics 2
if (plotCount > 1) {
  set key at screen 0.512,(red_pos_y + 0.0065) center center vertical Left reverse opaque enhanced autotitles box maxrows 1 width (key_width+1) samplen 1.75 font ",14" spacing 1.3
} else {
  if (srcFile1_title[1:6] eq "merkle" || (exists("srcFile3_title") && srcFile3_title[1:6] eq "merkle") || (exists("srcFile4_title") && srcFile4_title[1:6] eq "merkle")) {
    set key top left horizontal Left reverse opaque enhanced autotitles box maxcols 1 width key_width samplen 1.5 font ",13"
  } else {
    set key bottom right horizontal Right noreverse opaque enhanced autotitles box maxcols 1 width key_width samplen 1.5 font ",13"
  }
}

LABEL = "⇡naïve approach: ≥" . (systemSize*(128+32)/8/1024) . " KiB"
set obj 10 rect at graph 0.5,0.96 size char (strlen(LABEL)-6), char 1
set obj 10 fillstyle solid noborder front
set label 10 at graph 0.5,0.96 LABEL front center font ",12"

plot for [i=1:plotCount] "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(kB(column(col_bw_rc_size)+column(col_bw_rc2_size))) with boxes notitle ls i fs solid 0.3, \
     for [i=1:plotCount] "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(kB(column(col_bw_rc_size))) with boxes t get_title(i) ls i, \
     for [i=1:plotCount] "<awk '$" . col_ftype . " == \"update\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(kB(column(col_bw_rc_size)+column(col_bw_rc2_size))):(kB(stderrSum(column(col_sd_bw_rc_size), column(col_sd_bw_rc2_size)))) with yerrorbars notitle ls (plotCount > 1 ? (100+i) : 100)

set size all_width_r,bw_height
set origin 0.49,0
set xlabel "total δ, regen" font ",16"
unset key
unset ylabel
unset ytics
set grid y2tics
set y2tics mirror format "%-3.0f" scale 0.8
set my2tics 2

plot for [i=1:plotCount] "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(kB(column(col_bw_rc_size)+column(col_bw_rc2_size))) axes x1y2 with boxes notitle ls (plotCount > 1 ? i : 2) fs solid 0.3, \
     for [i=1:plotCount] "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(kB(column(col_bw_rc_size))) axes x1y2 with boxes t get_title(i) ls (plotCount > 1 ? i : 2), \
     for [i=1:plotCount] "<awk '$" . col_ftype . " == \"regen\"' " . get_file(i) \
 u (plotShift(column(col_fprob), i)):(kB(column(col_bw_rc_size)+column(col_bw_rc2_size))):(kB(stderrSum(column(col_sd_bw_rc_size), column(col_sd_bw_rc2_size)))) axes x1y2 with yerrorbars notitle ls (plotCount > 1 ? (100+i) : 100)


Fix bug where we printed the month number instead of the day number *blush*

git-svn-id: a4a6f32337ebd29ad4763b423022f00f68d1c7b7@7980 91177308-0d34-0410-b5e6-96231b3b80d8

set terminal png

##------- Plot small Date vs LOC ----
set output "running_loc.png"
set xlabel "Date" "TimesRoman,24"
set ylabel "Lines of Code" "TimesRoman,24"
set xdata time
set timefmt "%Y-%m-%d:"
set format x "%b %d, %Y"

## Various labels for the graph
set label "Removed\ndummy\nfunction" at "2003-07-30:", 150000

set size .75,.75
plot "running_loc.txt" using 1:2 title '', \
     "running_loc.txt" using 1:2 title "Date vs. Lines of Code" with lines

##------- Plot large Date vs LOC ----
set size 1.5,1.5
set output "running_loc_large.png"
plot "running_loc.txt" using 1:2 title '', \
     "running_loc.txt" using 1:2 title "Date vs. Lines of Code" with lines

# Delete all labels...
set nolabel

set terminal png

##------- Plot small Date vs LOC ----
set output "running_loc.png"
set xlabel "Date" "TimesRoman,24"
set ylabel "Lines of Code" "TimesRoman,24"
set xdata time
set timefmt "%Y-%m-%d:"
set format x "%b %m, %Y"

## Various labels for the graph
set label "Removed\ndummy\nfunction" at "2003-07-30:", 150000

set size .75,.75
plot "running_loc.txt" using 1:2 title '', \
     "running_loc.txt" using 1:2 title "Date vs. Lines of Code" with lines

##------- Plot large Date vs LOC ----
set size 1.5,1.5
set output "running_loc_large.png"
plot "running_loc.txt" using 1:2 title '', \
     "running_loc.txt" using 1:2 title "Date vs. Lines of Code" with lines

# Delete all labels...
set nolabel


work around make-3.80 bug

work around make-3.80 bug

git-svn-id: 4e7379b20b57f8e3dde5a0b7363f233184647162@1508 4e380d45-d1fd-0310-85a7-d18ec86df0ad

############################################################################
#  Makefile.subdir.gnu
#
#  Part of the STXXL. See http://stxxl.sourceforge.net
#
#  Copyright (C) 2007 Andreas Beckmann <beckmann@mpi-inf.mpg.de>
#
#  Distributed under the Boost Software License, Version 1.0.
#  (See accompanying file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)
############################################################################

include $(TOPDIR)/make.settings

TEST_BINARIES		 = $(TESTS) $(TESTS-yes) $(TESTS-yesyes)
SKIPPED_TEST_BINARIES	 = $(TESTS-) $(TESTS-no) $(TESTS-yesno) $(TESTS-noyes) $(TESTS-nono)

tests: $(TEST_BINARIES:%=%.$(bin))

lib: $(LIB_SRC:.cpp=.$o)

clean::
	$(RM) *.$o
	$(RM) *.$d *.dT
	$(RM) $(TEST_BINARIES:=.$(bin))
	$(RM) $(SKIPPED_TEST_BINARIES:=.$(bin))

-include *.d

# Work around compiler bugs:
compiler_version	:= $(shell $(COMPILER) -v 2>&1 | tr ' ' '_')
bitness			:= $(shell file ../common/version.$(o) 2>/dev/null)
# usage: e.g. $(call needs_override,gcc_version_4.2,32-bit,3,[-g|any|none])
needs_override		?= $(and $(findstring $1,$(compiler_version)),\
				$(or $(filter any,$2),$(filter $2,$(bitness))),\
				$(filter $3,$(OPT_LEVEL)),\
				$(or $(filter any,$4),$(if $(filter none,$4),$(if $(DEBUG),,empty)),$(filter $4,$(DEBUG))))
# usage: $(call reduce_optimization,from,to,target,compiler,bits,debug[,type])
reduce_optimization	?= $(if $(call needs_override,$4,$5,$1,$6),$3.$($(or $(strip $7),bin)): OPT_LEVEL=$2)

.SECONDARY:

.PHONY: tests lib clean

############################################################################
#  Makefile.subdir.gnu
#
#  Part of the STXXL. See http://stxxl.sourceforge.net
#
#  Copyright (C) 2007 Andreas Beckmann <beckmann@mpi-inf.mpg.de>
#
#  Distributed under the Boost Software License, Version 1.0.
#  (See accompanying file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)
############################################################################

include $(TOPDIR)/make.settings

TEST_BINARIES		 = $(TESTS) $(TESTS-yes) $(TESTS-yesyes)
SKIPPED_TEST_BINARIES	 = $(TESTS-) $(TESTS-no) $(TESTS-yesno) $(TESTS-noyes) $(TESTS-nono)

tests: $(TEST_BINARIES:=.$(bin))

lib: $(LIB_SRC:.cpp=.$o)

clean::
	$(RM) *.$o
	$(RM) *.$d *.dT
	$(RM) $(TEST_BINARIES:=.$(bin))
	$(RM) $(SKIPPED_TEST_BINARIES:=.$(bin))

-include *.d

# Work around compiler bugs:
compiler_version	:= $(shell $(COMPILER) -v 2>&1 | tr ' ' '_')
bitness			:= $(shell file ../common/version.$(o) 2>/dev/null)
# usage: e.g. $(call needs_override,gcc_version_4.2,32-bit,3,[-g|any|none])
needs_override		?= $(and $(findstring $1,$(compiler_version)),\
				$(or $(filter any,$2),$(filter $2,$(bitness))),\
				$(filter $3,$(OPT_LEVEL)),\
				$(or $(filter any,$4),$(if $(filter none,$4),$(if $(DEBUG),,empty)),$(filter $4,$(DEBUG))))
# usage: $(call reduce_optimization,from,to,target,compiler,bits,debug[,type])
reduce_optimization	?= $(if $(call needs_override,$4,$5,$1,$6),$3.$($(or $(strip $7),bin)): OPT_LEVEL=$2)

.SECONDARY:

.PHONY: tests lib clean


Y stats

Y stats

#!/usr/bin/env gnuplot

# graph of memory usage

# datafiles
ifnameh = "/tmp/lnxdiagd/mysql/sql14h.csv"
ifnamed = "/tmp/lnxdiagd/mysql/sql14d.csv"
ifnamew = "/tmp/lnxdiagd/mysql/sql14w.csv"
set output  "/tmp/lnxdiagd/site/img/day14.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera,9" size 1280,320
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid front
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
# Positions of split between graphs
LMARG = 0.06
LMPOS = 0.40
MRPOS = 0.73
RMARG = 0.94

min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 2 name "X" nooutput
Xh_min = X_min + utc_offset - 946684800
Xh_max = X_max + utc_offset - 946684800

# stats to be calculated here of column 11 (Swap memory used)
stats ifnameh using 11 name "Yh" nooutput

# ********************************************************* Statistics (M) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 2 name "X" nooutput
Xd_min = X_min + utc_offset - 946684800
Xd_max = X_max + utc_offset - 946684800

# stats to be calculated here of column 11 (Swap memory used)
stats ifnameh using 11 name "Yd" nooutput

# ********************************************************* Statistics (L) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamew using 2 name "X" nooutput
Xw_min = X_min + utc_offset - 946684800
Xw_max = X_max + utc_offset - 946684800

# stats to be calculated here of column 11 (Swap memory used)
stats ifnameh using 11 name "Yw" nooutput

Ymax = max(max(Yd_max, Yh_max), Yw_max) * -1

set multiplot layout 1, 3 title "Memory Usage ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       LEFT PLOT: past week
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past week"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%a %d"            # Display time in 24 hour notation on the X axis
set xrange [ Xw_min : Xw_max ]

# ***************************************************************** Y-axis *****
set ylabel "Usage [%]"
set autoscale y
set format y "%4.0s%c"

# ***************************************************************** Legend *****
set key opaque box inside top left
set key samplen 0.1
set key reverse horizontal Left
set key maxcols 4

# ***************************************************************** Output *****
# set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
# set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
#set object 1 rect from screen 0,0 to screen 1,1 behind
#set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
#set object 2 rect from graph 0,0 to graph 1,1 behind
#set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder

set lmargin at screen LMARG
set rmargin at screen LMPOS

# ***** PLOT *****
set style data boxes
set style fill solid noborder

plot ifnamew \
      using ($2+utc_offset):($5+$6+$7+$8) title "free"    fc rgb "#229922"  \
  ,'' using ($2+utc_offset):($5+$6+$7)    title "cached"  fc "yellow"       \
  ,'' using ($2+utc_offset):($5+$6)       title "buffers" fc "blue"         \
  ,'' using ($2+utc_offset):5             title "used"    fc rgb "#bb0000"  \
  ,'' using ($2+utc_offset):($11*-1)      title "swap"    fc rgb "#ee0000"  \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     MIDDLE PLOT:  past day
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past day"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xd_min : Xd_max ]

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set autoscale y

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen LMPOS+0.001
set rmargin at screen MRPOS

# ***** PLOT *****
plot ifnamed \
      using ($2+utc_offset):($5+$6+$7+$8) fc rgb "#229922"  \
  ,'' using ($2+utc_offset):($5+$6+$7)    fc "yellow"       \
  ,'' using ($2+utc_offset):($5+$6)       fc "blue"         \
  ,'' using ($2+utc_offset):5             fc rgb "#bb0000"  \
  ,'' using ($2+utc_offset):($11*-1)      fc rgb "#ee0000"  \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      RIGHT PLOT: past hour
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past hour"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xh_min : Xh_max ]
set xtics textcolor rgb "red"

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set autoscale y

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen MRPOS+0.001
set rmargin at screen RMARG

# ***** PLOT *****
plot ifnameh \
      using ($2+utc_offset):($5+$6+$7+$8) fc rgb "#229922"  \
  ,'' using ($2+utc_offset):($5+$6+$7)    fc "yellow"       \
  ,'' using ($2+utc_offset):($5+$6)       fc "blue"         \
  ,'' using ($2+utc_offset):5             fc rgb "#bb0000"  \
  ,'' using ($2+utc_offset):($11*-1)      fc rgb "#ee0000"  \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                 FINALIZING
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

unset multiplot

#!/usr/bin/env gnuplot

# graph of memory usage

# datafiles
ifnameh = "/tmp/lnxdiagd/mysql/sql14h.csv"
ifnamed = "/tmp/lnxdiagd/mysql/sql14d.csv"
ifnamew = "/tmp/lnxdiagd/mysql/sql14w.csv"
set output  "/tmp/lnxdiagd/site/img/day14.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera,9" size 1280,320
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid front
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
# Positions of split between graphs
LMARG = 0.06
LMPOS = 0.40
MRPOS = 0.73
RMARG = 0.94

min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 2 name "X" nooutput

Xh_min = X_min + utc_offset - 946684800
Xh_max = X_max + utc_offset - 946684800

# ********************************************************* Statistics (M) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 2 name "X" nooutput

Xd_min = X_min + utc_offset - 946684800
Xd_max = X_max + utc_offset - 946684800

# ********************************************************* Statistics (L) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamew using 2 name "X" nooutput
Xw_min = X_min + utc_offset - 946684800
Xw_max = X_max + utc_offset - 946684800

set multiplot layout 1, 3 title "Memory Usage ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       LEFT PLOT: past week
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past week"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%a %d"            # Display time in 24 hour notation on the X axis
set xrange [ Xw_min : Xw_max ]

# ***************************************************************** Y-axis *****
set ylabel "Usage [%]"
set autoscale y
set format y "%4.0s%c"

# ***************************************************************** Legend *****
set key opaque box inside top left
set key samplen 0.1
set key reverse horizontal Left
set key maxcols 4

# ***************************************************************** Output *****
# set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
# set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
#set object 1 rect from screen 0,0 to screen 1,1 behind
#set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
#set object 2 rect from graph 0,0 to graph 1,1 behind
#set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder

set lmargin at screen LMARG
set rmargin at screen LMPOS

# ***** PLOT *****
set style data boxes
set style fill solid noborder

plot ifnamew \
      using ($2+utc_offset):($5+$6+$7+$8) title "free"    fc rgb "#229922"  \
  ,'' using ($2+utc_offset):($5+$6+$7)    title "cached"  fc "yellow"       \
  ,'' using ($2+utc_offset):($5+$6)       title "buffers" fc "blue"         \
  ,'' using ($2+utc_offset):5             title "used"    fc rgb "#bb0000"  \
  ,'' using ($2+utc_offset):($11*-1)      title "swap"    fc rgb "#ee0000"  \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     MIDDLE PLOT:  past day
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past day"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xd_min : Xd_max ]

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set autoscale y

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen LMPOS+0.001
set rmargin at screen MRPOS

# ***** PLOT *****
plot ifnamed \
      using ($2+utc_offset):($5+$6+$7+$8) fc rgb "#229922"  \
  ,'' using ($2+utc_offset):($5+$6+$7)    fc "yellow"       \
  ,'' using ($2+utc_offset):($5+$6)       fc "blue"         \
  ,'' using ($2+utc_offset):5             fc rgb "#bb0000"  \
  ,'' using ($2+utc_offset):($11*-1)      fc rgb "#ee0000"  \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      RIGHT PLOT: past hour
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past hour"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xh_min : Xh_max ]
set xtics textcolor rgb "red"

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set autoscale y

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen MRPOS+0.001
set rmargin at screen RMARG

# ***** PLOT *****
plot ifnameh \
      using ($2+utc_offset):($5+$6+$7+$8) fc rgb "#229922"  \
  ,'' using ($2+utc_offset):($5+$6+$7)    fc "yellow"       \
  ,'' using ($2+utc_offset):($5+$6)       fc "blue"         \
  ,'' using ($2+utc_offset):5             fc rgb "#bb0000"  \
  ,'' using ($2+utc_offset):($11*-1)      fc rgb "#ee0000"  \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                 FINALIZING
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

unset multiplot


test 'bad' context and div-by-zero

test 'bad' context and div-by-zero

:- use_module(library(debug)).
:- use_module(library(plunit)).

:- use_module(library(lists)).
:- use_module(library(assoc)).

:- use_module('../lib/classad_parser.pl').
:- use_module('../lib/classad_eval.pl').

:- begin_tests(classad_eval_ut).

test('error 1') :-
    parse("[a = error;]", C),
    eval(a, C, R),
    assertion(R == error).

test('undefined 1') :-
    parse("[a = undefined;]", C),
    eval(a, C, R),
    assertion(R == undefined).

test('true 1') :-
    parse("[a = true;]", C),
    eval(a, C, R),
    assertion(R == true).

test('false 1') :-
    parse("[a = false;]", C),
    eval(a, C, R),
    assertion(R == false).

test('number 1') :-
    parse("[a = 0;]", C),
    eval(a, C, R),
    assertion(R == 0).

test('string 1') :-
    parse("[a = \"fred and wilma\";]", C),
    eval(a, C, R),
    assertion(R == '[str]'('fred and wilma')).

test('classad 1') :-
    parse("[a = [b=0;];]", C),
    eval(a, C, R),
    assertion(functor(R,'[classad]',1)),
    eval(b, R, R2),
    assertion(R2 == 0).

test('list 0') :-
    parse("[a = {};]", C),
    eval(a, C, R),
    assertion(R == []).

test('list 1') :-
    parse("[a = {0};]", C),
    eval(a, C, R),
    assertion(R == [0]).

test('list 2') :-
    parse("[a = {0, true};]", C),
    eval(a, C, R),
    assertion(R == [0, true]).

test('list 3') :-
    parse("[x = 42; a = {0, true, x};]", C),
    eval(a, C, R),
    assertion(R == [0, true, 42]).

test('undefined var 1') :-
    parse("[]", C),
    eval(a, C, R),
    assertion(R == undefined).

test('select 1') :-
    parse("[a = [b=0;];]", C),
    eval(as_expr "a.b", C, R),
    assertion(R == 0).

test('select 2') :-
    parse("[a = [b=[c=42;];];]", C),
    eval(as_expr "a.b.c", C, R),
    assertion(R == 42).

test('select 3') :-
    parse("[a = [b=[c=42;];];]", C),
    eval(as_expr "a.z.c", C, R),
    assertion(R == undefined).

test('select 4') :-
    parse("[a = [z=0; b=[c=42;];];]", C),
    eval(as_expr "a.z.c", C, R),
    assertion(R == error).

test('parent 1') :-
    parse("[a = [b=parent.x; x=4;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    assertion(R == 42).

test('parent 2') :-
    parse("[a = [b=[c=parent.parent.x; x=4;]; x=2;]; x = 42;]", C),
    eval(as_expr "a.b.c", C, R),
    assertion(R == 42).

test('parent 3') :-
    parse("[a = [b=parent.parent.x; x=4;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    assertion(R == undefined).

test('parent 4') :-
    parse("[a = [b=parent.parent.parent.x; x=4;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    assertion(R == undefined).

test('var context pop 1') :-
    parse("[a = [b=x;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    assertion(R == 42).

test('var cyclic 1') :-
    parse("[a = b; b = a;]", C),
    eval(as_expr "a", C, R),
    assertion(R == undefined).

test('var cyclic 2') :-
    parse("[a = b+c; b = 1; c = 2 * d; d = a;]", C),
    eval(as_expr "a", C, R),
    assertion(R == undefined).

test('add 1') :-
    parse("[a = 1 + 2;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 3).

test('add 2') :-
    parse("[a = 1 + x; x=3.0;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 4.0).

test('add 3') :-
    parse("[a = 1 + x; x=3.0;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 4.0).

test('add 4') :-
    parse("[a = 1 + x;]", C),
    eval(as_expr "a", C, R),
    assertion(R == undefined).

test('add 5') :-
    parse("[a = 1 + x; x = true;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 2).

test('add 6') :-
    parse("[a = 1 + x; x = \"s\";]", C),
    eval(as_expr "a", C, R),
    assertion(R == error).

test('sub 1') :-
    parse("[a = 3 - 2;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 1).

test('mul 1') :-
    parse("[a = 3.0 * 2;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 6.0).

test('mul 2') :-
    parse("[a = 3 * 2;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 6).

test('divide 1') :-
    parse("[a = 10 / 2;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 5).

test('divide 2') :-
    parse("[a = 10 / 2.0;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 5.0).

test('divide 3') :-
    parse("[a = 10 / 0;]", C),
    eval(as_expr "a", C, R),
    assertion(R == error).

test('divide 4') :-
    parse("[a = 10 / 0.0;]", C),
    eval(as_expr "a", C, R),
    assertion(R == error).

test('&& 1') :-
    parse("[a = true && true;]", C),
    eval(as_expr "a", C, R),
    assertion(R == true).

test('&& 2') :-
    parse("[a = false && b;]", C),
    eval(as_expr "a", C, R),
    assertion(R == false).

test('&& 3') :-
    parse("[a = 0 && \"z\";]", C),
    eval(as_expr "a", C, R),
    assertion(R == false).

test('&& 4') :-
    parse("[a = 1 && \"z\";]", C),
    eval(as_expr "a", C, R),
    assertion(R == error).

test('&& 5') :-
    parse("[a = \"z\" && false;]", C),
    eval(as_expr "a", C, R),
    assertion(R == error).

test('&& 6') :-
    parse("[a = 1.0 && b;]", C),
    eval(as_expr "a", C, R),
    assertion(R == undefined).

test('&& 7') :-
    parse("[a = b && 1.0;]", C),
    eval(as_expr "a", C, R),
    assertion(R == undefined).

test('&& 8') :-
    parse("[a = b && 0;]", C),
    eval(as_expr "a", C, R),
    assertion(R == false).

:- end_tests(classad_eval_ut).

:- use_module(library(debug)).
:- use_module(library(plunit)).

:- use_module(library(lists)).
:- use_module(library(assoc)).

:- use_module('../lib/classad_parser.pl').
:- use_module('../lib/classad_eval.pl').

:- begin_tests(classad_eval_ut).

test('error 1') :-
    parse("[a = error;]", C),
    eval(a, C, R),
    assertion(R == error).

test('undefined 1') :-
    parse("[a = undefined;]", C),
    eval(a, C, R),
    assertion(R == undefined).

test('true 1') :-
    parse("[a = true;]", C),
    eval(a, C, R),
    assertion(R == true).

test('false 1') :-
    parse("[a = false;]", C),
    eval(a, C, R),
    assertion(R == false).

test('number 1') :-
    parse("[a = 0;]", C),
    eval(a, C, R),
    assertion(R == 0).

test('string 1') :-
    parse("[a = \"fred and wilma\";]", C),
    eval(a, C, R),
    assertion(R == '[str]'('fred and wilma')).

test('classad 1') :-
    parse("[a = [b=0;];]", C),
    eval(a, C, R),
    assertion(functor(R,'[classad]',1)),
    eval(b, R, R2),
    assertion(R2 == 0).

test('list 0') :-
    parse("[a = {};]", C),
    eval(a, C, R),
    assertion(R == []).

test('list 1') :-
    parse("[a = {0};]", C),
    eval(a, C, R),
    assertion(R == [0]).

test('list 2') :-
    parse("[a = {0, true};]", C),
    eval(a, C, R),
    assertion(R == [0, true]).

test('list 3') :-
    parse("[x = 42; a = {0, true, x};]", C),
    eval(a, C, R),
    assertion(R == [0, true, 42]).

test('undefined var 1') :-
    parse("[]", C),
    eval(a, C, R),
    assertion(R == undefined).

test('select 1') :-
    parse("[a = [b=0;];]", C),
    eval(as_expr "a.b", C, R),
    assertion(R == 0).

test('select 2') :-
    parse("[a = [b=[c=42;];];]", C),
    eval(as_expr "a.b.c", C, R),
    assertion(R == 42).

test('select 3') :-
    parse("[a = [b=[c=42;];];]", C),
    eval(as_expr "a.z.c", C, R),
    assertion(R == undefined).

test('parent 1') :-
    parse("[a = [b=parent.x; x=4;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    assertion(R == 42).

test('parent 2') :-
    parse("[a = [b=[c=parent.parent.x; x=4;]; x=2;]; x = 42;]", C),
    eval(as_expr "a.b.c", C, R),
    assertion(R == 42).

test('parent 3') :-
    parse("[a = [b=parent.parent.x; x=4;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    assertion(R == undefined).

test('parent 4') :-
    parse("[a = [b=parent.parent.parent.x; x=4;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    assertion(R == undefined).

test('var context pop 1') :-
    parse("[a = [b=x;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    assertion(R == 42).

test('var cyclic 1') :-
    parse("[a = b; b = a;]", C),
    eval(as_expr "a", C, R),
    assertion(R == undefined).

test('var cyclic 2') :-
    parse("[a = b+c; b = 1; c = 2 * d; d = a;]", C),
    eval(as_expr "a", C, R),
    assertion(R == undefined).

test('add 1') :-
    parse("[a = 1 + 2;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 3).

test('add 2') :-
    parse("[a = 1 + x; x=3.0;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 4.0).

test('add 3') :-
    parse("[a = 1 + x; x=3.0;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 4.0).

test('add 4') :-
    parse("[a = 1 + x;]", C),
    eval(as_expr "a", C, R),
    assertion(R == undefined).

test('add 5') :-
    parse("[a = 1 + x; x = true;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 2).

test('add 6') :-
    parse("[a = 1 + x; x = \"s\";]", C),
    eval(as_expr "a", C, R),
    assertion(R == error).

test('sub 1') :-
    parse("[a = 3 - 2;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 1).

test('mul 1') :-
    parse("[a = 3.0 * 2;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 6.0).

test('mul 2') :-
    parse("[a = 3 * 2;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 6).

test('divide 1') :-
    parse("[a = 10 / 2;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 5).

test('divide 2') :-
    parse("[a = 10 / 2.0;]", C),
    eval(as_expr "a", C, R),
    assertion(R == 5.0).

test('&& 1') :-
    parse("[a = true && true;]", C),
    eval(as_expr "a", C, R),
    assertion(R == true).

test('&& 2') :-
    parse("[a = false && b;]", C),
    eval(as_expr "a", C, R),
    assertion(R == false).

test('&& 3') :-
    parse("[a = 0 && \"z\";]", C),
    eval(as_expr "a", C, R),
    assertion(R == false).

test('&& 4') :-
    parse("[a = 1 && \"z\";]", C),
    eval(as_expr "a", C, R),
    assertion(R == error).

test('&& 5') :-
    parse("[a = \"z\" && false;]", C),
    eval(as_expr "a", C, R),
    assertion(R == error).

test('&& 6') :-
    parse("[a = 1.0 && b;]", C),
    eval(as_expr "a", C, R),
    assertion(R == undefined).

test('&& 7') :-
    parse("[a = b && 1.0;]", C),
    eval(as_expr "a", C, R),
    assertion(R == undefined).

test('&& 8') :-
    parse("[a = b && 0;]", C),
    eval(as_expr "a", C, R),
    assertion(R == false).

:- end_tests(classad_eval_ut).


rrepair, plots: add the new col_merkle_num_trees column definition

col_id = 1
col_nodes = 2
col_dbsize = 3
col_fprob = 4
col_round = 5
col_recon_p1e = 6
col_merkle_bucket = 7
col_merkle_branch = 8
col_art_corr_factor = 9
col_art_leaf_fpr = 10
col_art_inner_fpr = 11
col_missing = 12
col_regen = 13
col_outdated = 14
col_updated = 15
col_bw_rc_size = 16
col_bw_rc_msg = 17
col_bw_rc2_size = 18
col_bw_rc2_msg = 19
col_bw_rs_size = 20
col_bw_rs_msg = 21
col_bw_rs_kvv = 22
col_sd_missing = 23
col_sd_regen = 24
col_sd_outdated = 25
col_sd_updated = 26
col_sd_bw_rc_size = 27
col_sd_bw_rc_msg = 28
col_sd_bw_rc2_size = 29
col_sd_bw_rc2_msg = 30
col_sd_bw_rs_size = 31
col_sd_bw_rs_msg = 32
col_sd_bw_rs_kvv = 33
col_min_missing = 34
col_max_missing = 35
col_min_regen = 36
col_max_regen = 37
col_min_outdated = 38
col_max_outdated = 39
col_min_updated = 40
col_max_updated = 41
col_min_bw_rc_size = 42
col_max_bw_rc_size = 43
col_min_rc_msg = 44
col_max_rc_msg = 45
col_min_bw_rc2_size = 46
col_max_bw_rc2_size = 47
col_min_rc2_msg = 48
col_max_rc2_msg = 49
col_min_bw_rs_size = 50
col_max_bw_rs_size = 51
col_min_bw_rs_msg = 52
col_max_bw_rs_msg = 53
col_min_bw_rs_kvv = 54
col_max_bw_rs_kvv = 55
col_rc_method = 56
col_ring_type = 57
col_ddist = 58
col_ftype = 59
col_fdist = 60
col_dtype = 61
col_tprob = 62
col_merkle_num_trees = 63