1#!/bin/bash 2# 3# Copyright 2015 the V8 project authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7# Convenience Script used to rank GC NVP output. 8 9print_usage_and_die() { 10 echo "Usage: $0 [OPTIONS]" 11 echo "" 12 echo "OPTIONS" 13 echo " -r|--rank new-gen-rank|old-gen-rank GC mode to profile" 14 echo " (default: old-gen-rank)" 15 echo " -s|--sort avg|max sorting mode (default: max)" 16 echo " -t|--top-level include top-level categories" 17 echo " -c|--csv provide csv output" 18 echo " -f|--file FILE profile input in a file" 19 echo " (default: stdin)" 20 echo " -p|--percentiles comma separated percentiles" 21 exit 1 22} 23 24OP=old-gen-rank 25RANK_MODE=max 26TOP_LEVEL=no 27CSV="" 28LOGFILE=/dev/stdin 29PERCENTILES="" 30 31while [[ $# -ge 1 ]] 32do 33 key="$1" 34 case $key in 35 -r|--rank) 36 case $2 in 37 new-gen-rank|old-gen-rank) 38 OP="$2" 39 ;; 40 *) 41 print_usage_and_die 42 esac 43 shift 44 ;; 45 -s|--sort) 46 case $2 in 47 max|avg) 48 RANK_MODE=$2 49 ;; 50 *) 51 print_usage_and_die 52 esac 53 shift 54 ;; 55 -t|--top-level) 56 TOP_LEVEL=yes 57 ;; 58 -c|--csv) 59 CSV=" --csv " 60 ;; 61 -f|--file) 62 LOGFILE=$2 63 shift 64 ;; 65 -p|--percentiles) 66 PERCENTILES="--percentiles=$2" 67 shift 68 ;; 69 *) 70 break 71 ;; 72 esac 73 shift 74done 75 76if [[ $# -ne 0 ]]; then 77 echo "Unknown option(s): $@" 78 echo "" 79 print_usage_and_die 80fi 81 82INTERESTING_NEW_GEN_KEYS="\ 83 scavenge \ 84 weak \ 85 roots \ 86 old_new \ 87 semispace \ 88" 89 90INTERESTING_OLD_GEN_KEYS="\ 91 clear.dependent_code \ 92 clear.global_handles \ 93 clear.maps \ 94 clear.slots_buffer \ 95 clear.store_buffer \ 96 clear.string_table \ 97 clear.weak_collections \ 98 clear.weak_lists \ 99 evacuate.candidates \ 100 evacuate.clean_up \ 101 evacuate.copy \ 102 evacuate.update_pointers \ 103 evacuate.update_pointers.to_evacuated \ 104 evacuate.update_pointers.to_new \ 105 evacuate.update_pointers.weak \ 106 external.mc_prologue \ 107 external.mc_epilogue \ 108 external.mc_incremental_prologue \ 109 external.mc_incremental_epilogue \ 110 external.weak_global_handles \ 111 mark.finish_incremental \ 112 mark.roots \ 113 mark.weak_closure \ 114 mark.weak_closure.ephemeral \ 115 mark.weak_closure.weak_handles \ 116 mark.weak_closure.weak_roots \ 117 mark.weak_closure.harmony \ 118 sweep.code \ 119 sweep.map \ 120 sweep.old \ 121" 122 123if [[ "$TOP_LEVEL" = "yes" ]]; then 124 INTERESTING_OLD_GEN_KEYS="\ 125 ${INTERESTING_OLD_GEN_KEYS} \ 126 clear \ 127 evacuate \ 128 finish \ 129 incremental_finalize \ 130 mark \ 131 pause 132 sweep \ 133 " 134 INTERESTING_NEW_GEN_KEYS="\ 135 ${INTERESTING_NEW_GEN_KEYS} \ 136 " 137fi 138 139BASE_DIR=$(dirname $0) 140 141case $OP in 142 new-gen-rank) 143 cat $LOGFILE | grep "gc=s" \ 144 | $BASE_DIR/eval_gc_nvp.py \ 145 --no-histogram \ 146 --rank $RANK_MODE \ 147 $CSV \ 148 $PERCENTILES \ 149 ${INTERESTING_NEW_GEN_KEYS} 150 ;; 151 old-gen-rank) 152 cat $LOGFILE | grep "gc=ms" \ 153 | $BASE_DIR/eval_gc_nvp.py \ 154 --no-histogram \ 155 --rank $RANK_MODE \ 156 $CSV \ 157 $PERCENTILES \ 158 ${INTERESTING_OLD_GEN_KEYS} 159 ;; 160 *) 161 ;; 162esac 163