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 code \ 88 semispace \ 89 object_groups \ 90" 91 92INTERESTING_OLD_GEN_KEYS="\ 93 clear.code_flush \ 94 clear.dependent_code \ 95 clear.global_handles \ 96 clear.maps \ 97 clear.slots_buffer \ 98 clear.store_buffer \ 99 clear.string_table \ 100 clear.weak_cells \ 101 clear.weak_collections \ 102 clear.weak_lists \ 103 evacuate.candidates \ 104 evacuate.clean_up \ 105 evacuate.copy \ 106 evacuate.update_pointers \ 107 evacuate.update_pointers.to_evacuated \ 108 evacuate.update_pointers.to_new \ 109 evacuate.update_pointers.weak \ 110 external.mc_prologue \ 111 external.mc_epilogue \ 112 external.mc_incremental_prologue \ 113 external.mc_incremental_epilogue \ 114 external.weak_global_handles \ 115 mark.finish_incremental \ 116 mark.prepare_code_flush \ 117 mark.roots \ 118 mark.weak_closure \ 119 mark.weak_closure.ephemeral \ 120 mark.weak_closure.weak_handles \ 121 mark.weak_closure.weak_roots \ 122 mark.weak_closure.harmony \ 123 sweep.code \ 124 sweep.map \ 125 sweep.old \ 126" 127 128if [[ "$TOP_LEVEL" = "yes" ]]; then 129 INTERESTING_OLD_GEN_KEYS="\ 130 ${INTERESTING_OLD_GEN_KEYS} \ 131 clear \ 132 evacuate \ 133 finish \ 134 incremental_finalize \ 135 mark \ 136 pause 137 sweep \ 138 " 139 INTERESTING_NEW_GEN_KEYS="\ 140 ${INTERESTING_NEW_GEN_KEYS} \ 141 " 142fi 143 144BASE_DIR=$(dirname $0) 145 146case $OP in 147 new-gen-rank) 148 cat $LOGFILE | grep "gc=s" \ 149 | $BASE_DIR/eval_gc_nvp.py \ 150 --no-histogram \ 151 --rank $RANK_MODE \ 152 $CSV \ 153 $PERCENTILES \ 154 ${INTERESTING_NEW_GEN_KEYS} 155 ;; 156 old-gen-rank) 157 cat $LOGFILE | grep "gc=ms" \ 158 | $BASE_DIR/eval_gc_nvp.py \ 159 --no-histogram \ 160 --rank $RANK_MODE \ 161 $CSV \ 162 $PERCENTILES \ 163 ${INTERESTING_OLD_GEN_KEYS} 164 ;; 165 *) 166 ;; 167esac 168