mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
4.2 KiB

  1. #!/bin/bash
  2. #
  3. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  4. #
  5. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  6. # Please add additional copyright information _after_ the line containing
  7. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  8. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  9. #
  10. # ROCK Linux: rock-src/scripts/Create-ParaSim
  11. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  12. #
  13. # This program is free software; you can redistribute it and/or modify
  14. # it under the terms of the GNU General Public License as published by
  15. # the Free Software Foundation; either version 2 of the License, or
  16. # (at your option) any later version. A copy of the GNU General Public
  17. # License can be found at Documentation/COPYING.
  18. #
  19. # Many people helped and are helping developing ROCK Linux. Please
  20. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  21. # file for details.
  22. #
  23. # --- ROCK-COPYRIGHT-NOTE-END ---
  24. config=default
  25. jobs="" ; x11=0
  26. while [ "$1" ] ; do
  27. case "$1" in
  28. -cfg) config=$2 ; shift ; shift ;;
  29. -jobs) jobs=$2 ; shift ; shift ;;
  30. -x11) x11=1 ; shift ;;
  31. *) echo "Usage: $0 [ -cfg <config> ] [ -x11 ]" \
  32. "[ -jobs <N>[,<N>[,...]]]"
  33. echo
  34. echo " \"Simulate\" a parallel build and output a graph showing how many parallel"
  35. echo " jobs are available for building in which phase of the build."
  36. echo
  37. echo " -cfg <config> the configuration to use"
  38. echo " -x11 graph the results with 'gnuplot'"
  39. echo " -jobs <N>[,<N>[,...]]] compare the reference build to cluster builds"
  40. echo " with N nodes"
  41. echo
  42. echo " For details, see Documentation/BUILD-CLUSTER."
  43. exit 1 ;;
  44. esac
  45. done
  46. . scripts/parse-config
  47. dir=src.parasim.$(cksum config/$config/packages | cut -f1 -d' ')
  48. echo "Building parasim in $dir."
  49. if [ "$jobs" ] ; then
  50. maxjobs=0
  51. for x in $( echo $jobs | tr , ' ' ) ; do
  52. [ $maxjobs -lt $x ] && maxjobs=$x
  53. if [ ! -f "$dir/parasim_$x.dat" ] ; then
  54. rm -rf $dir/logs_$x
  55. perl scripts/parasim2.pl $dir $config $x
  56. else
  57. echo "Using cached data in $dir/parasim_$x.dat."
  58. fi
  59. done
  60. {
  61. jobstotal=$( echo `wc -l < $dir/parasim_$maxjobs.dat` )
  62. echo 'set data style lines'
  63. echo 'set title "ROCK Linux Parallel Build' \
  64. 'Simulation ('$jobstotal' Jobs Total)"'
  65. echo 'set xlabel "Hours (on reference hardware)"'
  66. echo 'set ylabel "Parallel Jobs"'
  67. echo "plot [0:*] [0:$(( $maxjobs + 1 ))] \\"
  68. next=""
  69. for x in $( echo $jobs | tr , ' ' ) ; do
  70. tm=$( tail -n 1 $dir/parasim_$x.dat | cut -f1 | \
  71. awk -F. '{ printf("%02d:%02d\n",
  72. $1, 60*("0." $2)); }' )
  73. echo -en "$next" ; next=', \\\n'
  74. echo -n " \"parasim_$x.dat\" title \"Build with" \
  75. "$x parallel jobs ($tm)\" with steps lw 3"
  76. done
  77. } > $dir/parasim_$jobs.gnuplot
  78. cmd="perl scripts/parasim3.pl"
  79. for x in $( echo $jobs | tr , ' ' )
  80. do cmd="$cmd $dir/parasim_$x.dat" ; done
  81. eval "$cmd" > $dir/parasim_$jobs.txt
  82. if [ "$x11" = 1 ] ; then
  83. cd $dir ; gnuplot -persist parasim_$jobs.gnuplot
  84. else
  85. cat $dir/parasim_$jobs.txt
  86. fi
  87. exit
  88. fi
  89. mkdir -p $dir/logs
  90. if [ ! -f $dir/parasim.dat ] ; then
  91. echo -n "Simulation running ..."
  92. rm -rf $dir/logs $dir/parasim.new
  93. mkdir -p $dir/logs
  94. while
  95. ./scripts/Create-PkgQueue -cfg $config \
  96. -logdir $dir/logs | sort -r -n -k2 > $dir/queue.txt
  97. [ -s $dir/queue.txt ]
  98. do
  99. next="`head -n 1 $dir/queue.txt`" ; set $next
  100. qid="$1-$6" ; touch $dir/logs/$qid.log
  101. printf "%5d %5d %-30s %s\n" $(wc -l < $dir/queue.txt) \
  102. $2 $qid "$( cut -f1,7 -d' ' $dir/queue.txt | \
  103. tail -n +2 | tr '\n ' ' -' )" >> $dir/parasim.new
  104. echo -n .
  105. done
  106. mv $dir/parasim.new $dir/parasim.dat
  107. echo
  108. else
  109. echo "Using cached data in $dir/parasim.dat."
  110. fi
  111. jobstotal=$( echo `wc -l < $dir/parasim.dat` )
  112. cat > $dir/parasim.gnuplot <<- EOT
  113. set title "ROCK Linux Parallel Build Simulation ($jobstotal Jobs Total)"
  114. set xlabel "Number of Jobs build so far"
  115. set ylabel "Possible Parallel Jobs"
  116. plot 'parasim.dat' using 1 title "Parallel Jobs" with steps lw 3
  117. EOT
  118. perl scripts/parasim1.pl $dir/parasim.dat 0 > $dir/parasim.txt
  119. if [ "$x11" = 1 ] ; then
  120. cd $dir ; gnuplot -persist parasim.gnuplot
  121. else
  122. cat $dir/parasim.txt
  123. fi