utreexo icon indicating copy to clipboard operation
utreexo copied to clipboard

Data of how many times swapNodes was called on each row

Open kcalvinalvin opened this issue 5 years ago • 0 comments

Per @adiabat's suggestion, I collected the data on how many swapNodes() were called in each row. This was done by putting a println: fmt.Printf("swapNodes on row:%05d, forestRows:%05d\n", r, f.rows)

above this line. https://github.com/mit-dci/utreexo/blob/b3afd5d7a3f0fc297c2ce1d936b6bf87edd6fd61/accumulator/forest.go#L168

Figure_1

row 0: COUNT: 14266400
row 1: COUNT: 8382600
row 2: COUNT: 4746562
row 3: COUNT: 2648818
row 4: COUNT: 1406879
row 5: COUNT: 722279
row 6: COUNT: 358039
row 7: COUNT: 170496
row 8: COUNT: 79073
row 9: COUNT: 35974
row 10: COUNT: 15880
row 11: COUNT: 7146
row 12: COUNT: 3140
row 13: COUNT: 1330
row 14: COUNT: 504
row 15: COUNT: 203
row 16: COUNT: 70
row 17: COUNT: 41
row 18: COUNT: 15
row 19: COUNT: 6
row 20: COUNT: 0
row 21: COUNT: 2
row 22: COUNT: 0
row 23: COUNT: 0
row 24: COUNT: 0
row 25: COUNT: 0

used this bash script to extract from the log

  #!/usr/bin/env bash

  # set file
  FILE=$1

  getRow() {
          COUNT=0
          #cat $FILE | while read line; do
          while read line; do
                  printf -v j "%5d" $i
                  #echo "swapNodes on row:     $1"
                  if [[ $line == *"swapNodes on row:$j"* ]]; then
                          #echo MATCH
                          COUNT=$(($COUNT+1))
                          #echo $COUNT
                  fi
          done < $2

          echo "row $1: COUNT: $COUNT"
  }

  MAXNUM=$2

  echo "For forestRows=$MAXNUM"
  echo

  for i in $(seq 0 $MAXNUM); do
          #grep "swapNodes on row:    0"
          #$COUNT = $COUNT + 1
          getRow $i $FILE
          #printf "%5d\n" $i

And this python script for the graph

import matplotlib.pyplot as plt
import matplotlib.ticker as plticker
import numpy as np

TEST = [
    14266400,
    8382600,
    4746562,
    2648818,
    1406879,
    722279,
    358039,
    170496,
    79073,
    35974,
    15880,
    7146,
    3140,
    1330,
    504,
    203,
    70,
    41,
    15,
    6,
    0,
    2,
    0,
    0,
    0,
    0,
]

fig, ax = plt.subplots()

#fig.set_figheight(10)
#fig.set_figwidth(20)

ax.bar(np.arange(26), TEST, linewidth=5)
ax.ticklabel_format(useOffset=False, style='plain')

plt.xticks(np.arange(26))

for index, data in enumerate(TEST):
    plt.text(x=index-0.1, y=data, s=data, fontdict=dict(fontsize=7))

plt.title("Utreexo calls on rows. (testnet3 to block #1747721)")
plt.xlabel("rows called")
plt.ylabel("how many times called on each row")
plt.show()

kcalvinalvin avatar Sep 24 '20 07:09 kcalvinalvin