VirtualBox

Changeset 1925 in kBuild


Ignore:
Timestamp:
Oct 24, 2008 3:32:21 AM (16 years ago)
Author:
bird
Message:

kmk: some stats adjustments.

Location:
trunk/src/kmk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/Makefile.kmk

    r1918 r1925  
    176176kmk_DEFS.amd64 = CONFIG_WITH_OPTIMIZATION_HACKS
    177177kmk_DEFS.win = CONFIG_NEW_WIN32_CTRL_EVENT
     178kmk_DEFS.debug = CONFIG_WITH_MAKE_STATS
    178179
    179180kmk_SOURCES = \
    180181        main.c \
     182        kbuild.c \
    181183        read.c \
    182184        expreval.c \
     
    202204        version.c \
    203205        vpath.c \
    204         remote-stub.c \
    205         kbuild.c
     206        remote-stub.c
    206207
    207208#
  • trunk/src/kmk/hash.c

    r1915 r1925  
    488488           100.0 * (double) ht->ht_fill / (double) ht->ht_size);
    489489  fprintf (out_FILE, _("Rehash=%d, "), ht->ht_rehashes);
     490  MAKE_STATS(
    490491  fprintf (out_FILE, _("Collisions=%ld/%ld=%.0f%%"), ht->ht_collisions, ht->ht_lookups,
    491492           (ht->ht_lookups
    492493            ? (100.0 * (double) ht->ht_collisions / (double) ht->ht_lookups)
    493494            : 0));
     495  );
    494496}
    495497
  • trunk/src/kmk/make.h

    r1918 r1925  
    196196#endif
    197197
     198#ifdef CONFIG_WITH_MAKE_STATS
     199extern long make_stats_allocations;
     200extern unsigned long make_stats_allocated;
     201extern unsigned long make_stats_allocated_sum;
     202extern unsigned long make_stats_ht_lookups;
     203extern unsigned long make_stats_ht_collisions;
     204
     205# ifdef __APPLE__
     206#  include <malloc/malloc.h>
     207#  define SIZE_OF_HEAP_BLOCK(ptr)   malloc_size(ptr)
     208
     209# elif defined(__linux__) /* glibc */
     210#  include <malloc.h>
     211#  define SIZE_OF_HEAP_BLOCK(ptr)   malloc_usable_size(ptr)
     212
     213# elif defined(_MSC_VER) || defined(__OS2__)
     214#  define SIZE_OF_HEAP_BLOCK(ptr)   _msize(ptr)
     215
     216# else
     217#  include <stdlib.h>
     218#  define SIZE_OF_HEAP_BLOCK(ptr)   0
     219#endif
     220
     221# if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP)
     222#  define free xfree
     223extern void xfree (void *);
     224# endif
     225
     226# define MAKE_STATS_3(expr) do { expr; } while (0)
     227# define MAKE_STATS_2(expr) do { expr; } while (0)
     228# define MAKE_STATS(expr)   do { expr; } while (0)
     229#else
     230# define MAKE_STATS_3(expr) do { } while (0)
     231# define MAKE_STATS_2(expr) do { } while (0)
     232# define MAKE_STATS(expr)   do { } while (0)
     233#endif
     234
     235
    198236#ifndef CHAR_BIT
    199237# define CHAR_BIT 8
     
    514552  struct alloccache_free_ent *free_head;
    515553  unsigned int size;
    516   unsigned int alloc_count;
    517554  unsigned int total_count;
     555  unsigned long alloc_count;
     556  unsigned long free_count;
    518557  const char *name;
    519558  struct alloccache *next;
     
    545584  else
    546585    f = alloccache_alloc_grow (cache);
    547   cache->alloc_count++;
     586  MAKE_STATS(cache->alloc_count++;);
    548587  return f;
    549588}
     
    573612  f->next = cache->free_head;
    574613  cache->free_head = f;
    575   cache->alloc_count--;
     614  MAKE_STATS(cache->free_count++;);
    576615}
    577616
     
    855894#endif /* __EMX__ (bird) */
    856895
    857 #ifdef CONFIG_WITH_MAKE_STATS
    858 extern long make_stats_allocations;
    859 extern unsigned long make_stats_allocated;
    860 extern unsigned long make_stats_allocated_sum;
    861 extern unsigned long make_stats_ht_lookups;
    862 extern unsigned long make_stats_ht_collisions;
    863 
    864 # ifdef __APPLE__
    865 #  include <malloc/malloc.h>
    866 #  define SIZE_OF_HEAP_BLOCK(ptr)   malloc_size(ptr)
    867 
    868 # elif defined(__linux__) /* glibc */
    869 #  include <malloc.h>
    870 #  define SIZE_OF_HEAP_BLOCK(ptr)   malloc_usable_size(ptr)
    871 
    872 # elif defined(_MSC_VER) || defined(__OS2__)
    873 #  define SIZE_OF_HEAP_BLOCK(ptr)   _msize(ptr)
    874 
    875 # else
    876 #  include <stdlib.h>
    877 #  define SIZE_OF_HEAP_BLOCK(ptr)   0
    878 #endif
    879 
    880 # if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP)
    881 #  define free xfree
    882 extern void xfree (void *);
    883 # endif
    884 
    885 # define MAKE_STATS_3(expr) do { expr; } while (0)
    886 # define MAKE_STATS_2(expr) do { expr; } while (0)
    887 # define MAKE_STATS(expr)   do { expr; } while (0)
    888 #else
    889 # define MAKE_STATS_3(expr) do { } while (0)
    890 # define MAKE_STATS_2(expr) do { } while (0)
    891 # define MAKE_STATS(expr)   do { } while (0)
    892 #endif
    893 
    894896#ifdef CONFIG_WITH_IF_CONDITIONALS
    895897extern int expr_eval_if_conditionals(char *line, const struct floc *flocp);
  • trunk/src/kmk/misc.c

    r1918 r1925  
    12241224  cache->free_head   = NULL;
    12251225  cache->size        = act_size;
     1226  cache->total_count = 0;
    12261227  cache->alloc_count = 0;
    1227   cache->total_count = 0;
     1228  cache->free_count = 0;
    12281229  cache->name        = name;
    12291230  cache->grow_arg    = grow_arg;
     
    12571258  if (eat->free_head)
    12581259    {
     1260     unsigned int eat_in_use = eat->alloc_count - eat->free_count;
     1261     unsigned int dst_in_use = cache->alloc_count - cache->free_count;
    12591262     if (!cache->free_head)
    12601263       cache->free_head = eat->free_head;
    1261      else if (eat->total_count - eat->alloc_count < cache->total_count - cache->alloc_count)
     1264     else if (eat->total_count - eat_in_use < cache->total_count - dst_ins_use)
    12621265       {
    12631266         struct alloccache_free_ent *last = eat->free_head;
     
    12871290  /* and statistics */
    12881291  cache->alloc_count += eat->alloc_count;
    1289   cache->total_count += eat->total_count;
     1292  cache->free_count  += eat->free_count;
    12901293#else
    12911294  /* and statistics */
    12921295  cache->alloc_count += eat->alloc_count;
    1293   cache->total_count += eat->alloc_count;
    1294 #endif
     1296  cache->free_count  += eat->free_count;
     1297#endif
     1298  cache->total_count += eat->total_count;
    12951299
    12961300  /* unlink and disable the eat cache */
     
    13161320{
    13171321  printf (_("\n# Alloc Cache: %s\n"
    1318               "#  Items: size = %-3u  in-use = %-6d  total = %-6u\n"),
    1319           cache->name, cache->size, (int)cache->alloc_count, cache->total_count);
     1322              "#  Items: size = %-3u  total = %-6u"),
     1323          cache->name, cache->size, cache->total_count);
     1324  MAKE_STATS(printf (_("  in-use = %-6lu"),
     1325                     cache->alloc_count - cache->free_count););
     1326  MAKE_STATS(printf (_("\n#         alloc calls = %-7lu  free calls = %-7lu"),
     1327                     cache->alloc_count, cache->free_count););
     1328  printf ("\n");
    13201329}
    13211330
  • trunk/src/kmk/strcache2.c

    r1921 r1925  
    12661266
    12671267#ifdef STRCACHE2_USE_MASK
    1268   printf (_("%s  hash size = %u  mask = %#x  rehashed %u times  lookups = %lu\n"),
    1269           prefix, cache->hash_size, cache->hash_mask, rehashes, cache->lookup_count);
     1268  printf (_("%s  hash size = %u  mask = %#x  rehashed %u times"),
     1269          prefix, cache->hash_size, cache->hash_mask, rehashes);
    12701270#else
    1271   printf (_("%s  hash size = %u  div = %#x  rehashed %u times  lookups = %lu\n"),
    1272           prefix, cache->hash_size, cache->hash_div, rehashes, cache->lookup_count);
     1271  printf (_("%s  hash size = %u  div = %#x  rehashed %u times"),
     1272          prefix, cache->hash_size, cache->hash_div, rehashes);
    12731273#endif
    12741274  if (cache->lookup_count)
    1275     printf (_("%s  hash collisions 1st = %lu (%u%%)  2nd = %lu (%u%%)  3rd = %lu (%u%%)\n"),
     1275    printf (_("%s  lookups = %lu\n"
     1276              "%s  hash collisions 1st = %lu (%u%%)  2nd = %lu (%u%%)  3rd = %lu (%u%%)"),
     1277            prefix, cache->lookup_count,
    12761278            prefix,
    12771279            cache->collision_1st_count,  (unsigned int)((100.0 * cache->collision_1st_count) / cache->lookup_count),
    12781280            cache->collision_2nd_count,  (unsigned int)((100.0 * cache->collision_2nd_count) / cache->lookup_count),
    12791281            cache->collision_3rd_count,  (unsigned int)((100.0 * cache->collision_3rd_count) / cache->lookup_count));
    1280   printf (_("%s  hash insert collisions = %u (%u%%)\n"),
     1282  printf (_("\n%s  hash insert collisions = %u (%u%%)\n"),
    12811283          prefix, cache->collision_count,(unsigned int)((100.0 * cache->collision_count) / cache->count));
    12821284  printf (_("%s  %5u (%u%%) empty hash table slots\n"),
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette