From 4f94cb2b2796f8c6bfdda7b7d93c4bd341d5d1b2 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 23 Nov 2007 08:43:29 +0000 Subject: [PATCH] Clifford Wolf: Some improvements in scripts/Config profiler [2007111208134859100] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@8873 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- misc/tools-source/bash_profiler.c | 28 ++++++++++++++++++++++------ misc/tools-source/config_helper.c | 1 - scripts/Config | 21 +++++++++------------ scripts/config.func | 2 ++ scripts/config.in | 23 +++++++++++++++++++++++ 5 files changed, 56 insertions(+), 19 deletions(-) diff --git a/misc/tools-source/bash_profiler.c b/misc/tools-source/bash_profiler.c index ba0f2161d..a3dec6fd2 100644 --- a/misc/tools-source/bash_profiler.c +++ b/misc/tools-source/bash_profiler.c @@ -59,7 +59,8 @@ struct bprofent; struct bprofent { char *id; - int count; + int recursive; + int count, running; long long tv_sum, tv_start; struct bprofent *next; }; @@ -81,8 +82,13 @@ int bprof_builtin(WORD_LIST *list) if ( !strcmp(mode, "print") && !strcmp(name, "all") ) { while ( this ) { - printf("%7d %7Ld %10.3f %s\n", this->count, this->tv_sum, + printf("%7d %7Ld %10.3f %s", this->count, this->tv_sum, (float)this->tv_sum/this->count, this->id); + if (this->running) + printf(" (active)"); + if (this->recursive) + printf(" (recursive)"); + printf("\n"); this = this->next; } return 0; @@ -101,13 +107,23 @@ int bprof_builtin(WORD_LIST *list) } if ( !strcmp(mode, "start") ) { - this->tv_start = mytime(); + if (this->running++ == 0) + this->tv_start = mytime(); + if (this->running > 1) + this->recursive = 1; } else if ( !strcmp(mode, "stop") ) { - this->tv_sum += mytime() - this->tv_start; - this->count++; + if (--this->running == 0) { + this->tv_sum += mytime() - this->tv_start; + this->count++; + } } else if ( !strcmp(mode, "print") ) { - printf("%7d %7Ld %10.3f %s\n", this->count, this->tv_sum, + printf("%7d %7Ld %10.3f %s", this->count, this->tv_sum, (float)this->tv_sum/this->count, this->id); + if (this->running) + printf(" (active)"); + if (this->recursive) + printf(" (recursive)"); + printf("\n"); } return 0; diff --git a/misc/tools-source/config_helper.c b/misc/tools-source/config_helper.c index 25c0fa6ec..9c7a7ea09 100644 --- a/misc/tools-source/config_helper.c +++ b/misc/tools-source/config_helper.c @@ -276,7 +276,6 @@ int pkgswitch(int mode, char **args) int pkgfork(char *pkgname, char *xpkg, char** opt) { - struct package *fork, *pkg; int i, k; diff --git a/scripts/Config b/scripts/Config index 5e9c62599..dae253c47 100755 --- a/scripts/Config +++ b/scripts/Config @@ -114,19 +114,10 @@ else echo "Building src/bash_profiler.so." gcc -shared -fPIC -Wall -o src/bash_profiler.so misc/tools-source/bash_profiler.c || exit 1 fi + rm -f config.profile enable -f src/bash_profiler.so bprof || exit 1 bprof_print() { - bprof all print >> config.profile - awk ' - $4 == "profiled" { next; } - $4 != "main" { count["profiled"]+=$1; time["profiled"]+=$2; } - { count[$4]+=$1; time[$4]+=$2; } - END { - for (id in count) - printf "%7d %7Ld %10.3f %s\n", count[id], time[id], time[id]/count[id], id; - } - ' < config.profile | sort -n -k2 > config.profile.new - mv config.profile{.new,} + { echo "--- `date` ---"; bprof all print | sort -k2; } >> config.profile } fi @@ -286,8 +277,10 @@ while [ "$do_config_cycle" == 1 ] ; do esac done bprof main stop - bprof_print done + +bprof finish start + pkgout rm -f $swpdir/*.tmp @@ -315,3 +308,7 @@ for x in $( ls config/$config ); do [ -e $swpdir/$x ] || rm -f config/$config/$x done rm -rf $swpdir + +bprof finish stop +bprof_print + diff --git a/scripts/config.func b/scripts/config.func index b0894e2b5..006beb74b 100644 --- a/scripts/config.func +++ b/scripts/config.func @@ -189,6 +189,8 @@ else local pkg=$1 xpkg=$2 extraver ; shift 2 bprof pkgfork start + + # >50% of the Config time is spent in this line! parse_desc package/*/$pkg/$pkg.desc P V extraver=$( echo $desc_V 0 | cut -f2 -d" " ) diff --git a/scripts/config.in b/scripts/config.in index 5ebeac560..243df31a6 100644 --- a/scripts/config.in +++ b/scripts/config.in @@ -72,6 +72,8 @@ unset ${!CFGTEMP_*} +bprof rockconfig_preconfig start + if [ ! -e "$swpdir/preconfig.in.tmp" ] ; then grep -h -v "^#" architecture/*/preconfig.in \ misc/*/preconfig.in \ @@ -81,6 +83,9 @@ if [ ! -e "$swpdir/preconfig.in.tmp" ] ; then fi include "$swpdir/preconfig.in.tmp" +bprof rockconfig_preconfig stop +bprof rockconfig_arch start + comment_id '- Architecture, CPU and Optimization' COMMENT_ARCHCPUOPT block_begin 7 @@ -124,6 +129,9 @@ block_begin 7 fi block_end +bprof rockconfig_arch stop +bprof rockconfig_target start + comment ' ' comment_id '- Target Distribution' COMMENT_TARGET @@ -137,6 +145,9 @@ block_begin 7 bool 'Abbreviate ROCK Config ID with checksum' ROCKCFG_IDCKSUM 0 block_end +bprof rockconfig_target stop +bprof rockconfig_buildsys start + comment ' ' comment_id '- Build System Configuration' COMMENT_BUILD_SYS_CONF block_begin 3 @@ -194,8 +205,14 @@ block_begin 3 expert_end block_end +bprof rockconfig_buildsys stop +bprof rockconfig_noexpert start + include "misc/*/noexpertconfig.in" +bprof rockconfig_noexpert stop +bprof rockconfig_expert start + expert_begin comment ' ' comment '- Binary package format' @@ -258,6 +275,9 @@ fi include "$swpdir/config.in.tmp" expert_end +bprof rockconfig_expert stop +bprof rockconfig_postconfig start + [ "$ROCKCFG_CROSSBUILD" = 1 ] && ROCKCFG_ID="$ROCKCFG_ID-cross" [ "$ROCKCFG_PSEUDONATIVE" = 1 ] && ROCKCFG_ID="$ROCKCFG_ID-pseudonative" ROCKCFG_ID="$ROCKCFG_ID-$ROCKCFG_TARGET" @@ -309,3 +329,6 @@ fi var_append filterscript ' ' '/^[XO] --* / d ;' pkgfilter sed -e "$filterscript" + +bprof rockconfig_postconfig stop +