Changeset 3170 in kBuild
- Timestamp:
- Mar 21, 2018 12:32:27 PM (7 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/Makefile.kmk
r3156 r3170 225 225 kmk_DEFS += CONFIG_WITH_MAKE_STATS 226 226 endif 227 ifdef CONFIG_WITH_KMK_BUILTIN_STATS 228 kmk_DEFS += CONFIG_WITH_KMK_BUILTIN_STATS 229 endif 227 230 ifdef CONFIG_WITH_EVAL_COMPILER 228 231 kmk_DEFS += CONFIG_WITH_EVAL_COMPILER … … 231 234 kmk_DEFS += CONFIG_WITH_COMPILE_EVERYTHING 232 235 endif 236 233 237 #ifeq ($(KBUILD_TYPE).$(USERNAME),debug.bird) 234 238 # kmk_DEFS += CONFIG_WITH_COMPILER CONFIG_WITH_EVAL_COMPILER CONFIG_WITH_COMPILE_EVERYTHING -
trunk/src/kmk/kmkbuiltin.c
r3169 r3170 36 36 # include <io.h> 37 37 #endif 38 39 #include "makeint.h" 40 #include "job.h" 38 41 #if defined(KBUILD_OS_WINDOWS) && defined(CONFIG_NEW_WIN_CHILDREN) 39 # include "makeint.h"40 # include "job.h"41 42 # include "w32/winchildren.h" 42 43 #endif … … 231 232 * kmk built command. 232 233 */ 233 static const KMKBUILTINENTRY g_aBuilt ins[] =234 static const KMKBUILTINENTRY g_aBuiltIns[] = 234 235 { 235 236 #define BUILTIN_ENTRY(a_fn, a_sz, a_uFnSignature, fMpSafe, fNeedEnv) \ … … 266 267 }; 267 268 269 #ifdef CONFIG_WITH_KMK_BUILTIN_STATS 270 /** Statistics running in parallel to g_aBuiltIns. */ 271 struct 272 { 273 big_int cNs; 274 unsigned cTimes; 275 unsigned cAsyncTimes; 276 } g_aBuiltInStats[sizeof(g_aBuiltIns) / sizeof(g_aBuiltIns[0])]; 277 #endif 278 268 279 269 280 int kmk_builtin_command_parsed(int argc, char **argv, struct child *pChild, char ***ppapszArgvToSpawn, pid_t *pPidSpawned) … … 325 336 * Look up the builtin command in the table. 326 337 */ 327 pEntry = &g_aBuilt ins[0];328 cLeft = sizeof(g_aBuilt ins) / sizeof(g_aBuiltins[0]);338 pEntry = &g_aBuiltIns[0]; 339 cLeft = sizeof(g_aBuiltIns) / sizeof(g_aBuiltIns[0]); 329 340 while (cLeft-- > 0) 330 341 if ( pEntry->uName.cchAndStart != cchAndStart … … 340 351 #if defined(KBUILD_OS_WINDOWS) && defined(CONFIG_NEW_WIN_CHILDREN) 341 352 if (pEntry->fMpSafe) 353 { 342 354 rc = MkWinChildCreateBuiltIn(pEntry, argc, argv, pEntry->fNeedEnv ? pChild->environment : NULL, 343 355 pChild, pPidSpawned); 356 # ifdef CONFIG_WITH_KMK_BUILTIN_STATS 357 g_aBuiltInStats[pEntry - &g_aBuiltIns[0]].cAsyncTimes++; 358 # endif 359 } 344 360 else 345 361 #endif … … 350 366 * Call the worker function, making sure to preserve umask. 351 367 */ 368 #ifdef CONFIG_WITH_KMK_BUILTIN_STATS 369 big_int nsStart = nano_timestamp(); 370 #endif 352 371 int const iUmask = umask(0); /* save umask */ 353 372 umask(iUmask); … … 386 405 else 387 406 rc = 99; 407 388 408 g_progname = "kmk"; /* paranoia, make sure it's not pointing at a freed argv[0]. */ 389 409 umask(iUmask); /* restore it */ 410 411 #ifdef CONFIG_WITH_KMK_BUILTIN_STATS 412 g_aBuiltInStats[pEntry - &g_aBuiltIns[0]].cTimes++; 413 g_aBuiltInStats[pEntry - &g_aBuiltIns[0]].cNs += nano_timestamp() - nsStart; 414 #endif 390 415 } 391 416 return rc; … … 411 436 #endif 412 437 438 #ifdef CONFIG_WITH_KMK_BUILTIN_STATS 439 /** 440 * Prints the statistiscs to the given output stream. 441 */ 442 int kmk_builtin_print_stats(FILE *pOutput, const char *pszPrefix) 443 { 444 const unsigned cEntries = sizeof(g_aBuiltInStats) / sizeof(g_aBuiltInStats[0]); 445 unsigned i; 446 fprintf(pOutput, "\n%skmk built-in command statistics:\n", pszPrefix); 447 for (i = 0; i < cEntries; i++) 448 if (g_aBuiltInStats[i].cTimes > 0) 449 { 450 char szTotal[64]; 451 char szAvg[64]; 452 format_elapsed_nano(szTotal, sizeof(szTotal), g_aBuiltInStats[i].cNs); 453 format_elapsed_nano(szAvg, sizeof(szAvg), g_aBuiltInStats[i].cNs / g_aBuiltInStats[i].cTimes); 454 fprintf(pOutput, "%s kmk_builtin_%-9s: %4lu times, %9s total, %9s/call\n", 455 pszPrefix, g_aBuiltIns[i].uName.s.sz, g_aBuiltInStats[i].cTimes, szTotal, szAvg); 456 } 457 else if (g_aBuiltInStats[i].cAsyncTimes > 0) 458 fprintf(pOutput, "%s kmk_builtin_%-9s: %4lu times in worker thread\n", 459 pszPrefix, g_aBuiltIns[i].uName.s.sz, g_aBuiltInStats[i].cAsyncTimes); 460 } 461 #endif 462 -
trunk/src/kmk/kmkbuiltin.h
r3169 r3170 139 139 extern int kBuiltinOptChDir(char *pszCwd, size_t cbCwdBuf, const char *pszValue); 140 140 141 #ifdef CONFIG_WITH_KMK_BUILTIN_STATS 142 int kmk_builtin_print_stats(FILE *pOutput, const char *pszPrefix); 141 143 #endif 142 144 145 #endif 146 -
trunk/src/kmk/main.c
r3161 r3170 27 27 #ifdef KMK 28 28 # include "kbuild.h" 29 #endif 30 #ifdef CONFIG_WITH_KMK_BUILTIN_STATS 31 # include "kmkbuiltin.h" 29 32 #endif 30 33 … … 4174 4177 4175 4178 /* Allocators: */ 4176 # ifdef CONFIG_WITH_COMPILER4179 # ifdef CONFIG_WITH_COMPILER 4177 4180 kmk_cc_print_stats (); 4178 # endif4181 # endif 4179 4182 # ifndef CONFIG_WITH_STRCACHE2 4180 4183 strcache_print_stats ("#"); … … 4194 4197 print_kbuild_define_stats (); 4195 4198 # endif 4199 # ifdef CONFIG_WITH_KMK_BUILTIN_STATS 4200 kmk_builtin_print_stats (stdout, "# "); 4201 # endif 4196 4202 # ifdef CONFIG_WITH_COMPILER 4197 4203 kmk_cc_print_stats (); … … 4201 4207 printf (_("\n# Finished Make statistics on %s\n"), ctime (&when)); 4202 4208 } 4203 #endif 4209 #endif /* CONFIG_WITH_PRINT_STATS_SWITCH */ 4204 4210 4205 4211 static void -
trunk/src/kmk/makeint.h
r3162 r3170 1176 1176 #endif 1177 1177 1178 #if defined (CONFIG_WITH_NANOTS) || defined (CONFIG_WITH_PRINT_TIME_SWITCH) 1178 #if defined (CONFIG_WITH_NANOTS) || defined (CONFIG_WITH_PRINT_TIME_SWITCH) || defined(CONFIG_WITH_KMK_BUILTIN_STATS) 1179 1179 /* misc.c */ 1180 1180 extern big_int nano_timestamp (void); -
trunk/src/kmk/misc.c
r3140 r3170 1152 1152 #endif /* CONFIG_WITH_PRINT_STATS_SWITCH */ 1153 1153 1154 #if def CONFIG_WITH_PRINT_TIME_SWITCH1154 #if defined(CONFIG_WITH_PRINT_TIME_SWITCH) || defined(CONFIG_WITH_KMK_BUILTIN_STATS) 1155 1155 /* Get a nanosecond timestamp, from a monotonic time source if 1156 1156 possible. Returns -1 after calling error() on failure. */ … … 1249 1249 return sz; 1250 1250 } 1251 #endif /* CONFIG_WITH_PRINT_TIME_SWITCH */1252 1251 #endif /* CONFIG_WITH_PRINT_TIME_SWITCH || defined(CONFIG_WITH_KMK_BUILTIN_STATS) */ 1252
Note:
See TracChangeset
for help on using the changeset viewer.