eval_gc_time.sh 3.29 KB
Newer Older
1 2 3 4 5 6 7 8 9
#!/bin/bash
#
# Copyright 2015 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Convenience Script used to rank GC NVP output.

print_usage_and_die() {
10
  echo "Usage: $0 [OPTIONS]"
11
  echo ""
12 13 14 15 16 17 18 19
  echo "OPTIONS"
  echo  "  -r|--rank new-gen-rank|old-gen-rank    GC mode to profile"
  echo  "                                         (default: old-gen-rank)"
  echo  "  -s|--sort avg|max                      sorting mode (default: max)"
  echo  "  -t|--top-level                         include top-level categories"
  echo  "  -c|--csv                               provide csv output"
  echo  "  -f|--file FILE                         profile input in a file"
  echo  "                                         (default: stdin)"
20
  echo  "  -p|--percentiles                       comma separated percentiles"
21 22 23
  exit 1
}

24 25 26 27 28
OP=old-gen-rank
RANK_MODE=max
TOP_LEVEL=no
CSV=""
LOGFILE=/dev/stdin
29
PERCENTILES=""
30

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
while [[ $# -ge 1 ]]
do
  key="$1"
  case $key in
    -r|--rank)
      case $2 in
        new-gen-rank|old-gen-rank)
          OP="$2"
          ;;
        *)
          print_usage_and_die
      esac
      shift
      ;;
    -s|--sort)
      case $2 in
        max|avg)
          RANK_MODE=$2
          ;;
        *)
          print_usage_and_die
      esac
      shift
      ;;
    -t|--top-level)
      TOP_LEVEL=yes
      ;;
    -c|--csv)
      CSV=" --csv "
      ;;
    -f|--file)
      LOGFILE=$2
      shift
      ;;
65
    -p|--percentiles)
66 67 68
      PERCENTILES="--percentiles=$2"
      shift
      ;;
69 70 71 72 73 74
    *)
      break
      ;;
  esac
  shift
done
75

76 77 78 79
if [[ $# -ne 0 ]]; then
  echo "Unknown option(s): $@"
  echo ""
  print_usage_and_die
80
fi
81 82 83 84 85 86 87 88 89 90

INTERESTING_NEW_GEN_KEYS="\
  scavenge \
  weak \
  roots \
  old_new \
  semispace \
"

INTERESTING_OLD_GEN_KEYS="\
91 92 93 94 95 96 97 98 99
  clear.dependent_code \
  clear.global_handles \
  clear.maps \
  clear.slots_buffer \
  clear.string_table \
  clear.weak_collections \
  clear.weak_lists \
  evacuate.candidates \
  evacuate.clean_up \
100
  evacuate.copy \
101 102 103 104
  evacuate.update_pointers \
  evacuate.update_pointers.to_evacuated \
  evacuate.update_pointers.to_new \
  evacuate.update_pointers.weak \
105 106 107 108 109
  external.mc_prologue \
  external.mc_epilogue \
  external.mc_incremental_prologue \
  external.mc_incremental_epilogue \
  external.weak_global_handles \
110 111 112
  mark.finish_incremental \
  mark.roots \
  mark.weak_closure \
113 114 115 116
  mark.weak_closure.ephemeral \
  mark.weak_closure.weak_handles \
  mark.weak_closure.weak_roots \
  mark.weak_closure.harmony \
117 118 119
  sweep.code \
  sweep.map \
  sweep.old \
120 121
"

122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
if [[ "$TOP_LEVEL" = "yes" ]]; then
  INTERESTING_OLD_GEN_KEYS="\
    ${INTERESTING_OLD_GEN_KEYS} \
    clear \
    evacuate \
    finish \
    incremental_finalize \
    mark \
    pause
    sweep \
  "
  INTERESTING_NEW_GEN_KEYS="\
    ${INTERESTING_NEW_GEN_KEYS} \
  "
fi

138 139 140 141 142 143 144 145
BASE_DIR=$(dirname $0)

case $OP in
  new-gen-rank)
    cat $LOGFILE | grep "gc=s" \
      | $BASE_DIR/eval_gc_nvp.py \
      --no-histogram \
      --rank $RANK_MODE \
146
      $CSV \
147
      $PERCENTILES \
148 149 150
      ${INTERESTING_NEW_GEN_KEYS}
    ;;
  old-gen-rank)
151
    cat $LOGFILE | grep "gc=ms" \
152 153 154
      | $BASE_DIR/eval_gc_nvp.py \
      --no-histogram \
      --rank $RANK_MODE \
155
      $CSV \
156
      $PERCENTILES \
157 158 159 160 161
      ${INTERESTING_OLD_GEN_KEYS}
    ;;
  *)
    ;;
esac