VirtualBox

Changeset 1986 in kBuild


Ignore:
Timestamp:
Oct 28, 2008 1:59:10 AM (16 years ago)
Author:
bird
Message:

kmk: some make stats cleanup.

Location:
trunk/src/kmk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/function.c

    r1980 r1986  
    119119#ifdef CONFIG_WITH_MAKE_STATS
    120120long          make_stats_allocations = 0;
     121long          make_stats_reallocations = 0;
    121122unsigned long make_stats_allocated = 0;
    122 unsigned long make_stats_allocated_sum = 0;
    123123unsigned long make_stats_ht_lookups = 0;
    124124unsigned long make_stats_ht_collisions = 0;
     
    42334233    {
    42344234# ifdef CONFIG_WITH_MAKE_STATS
    4235       len = sprintf (buf, "alloc-cur: %5ld %6luKB (/%3luMB)  hash: %5lu %2lu%%",
     4235      len = sprintf (buf, "alloc-cur: %5ld/%3ld %3luMB  hash: %5lu %2lu%%",
    42364236                     make_stats_allocations,
    4237                      make_stats_allocated / 1024,
    4238                      make_stats_allocated_sum / (1024*1024),
     4237                     make_stats_reallocations,
     4238                     make_stats_allocated / (1024*1024),
    42394239                     make_stats_ht_lookups,
    42404240                     (make_stats_ht_collisions * 100) / make_stats_ht_lookups);
     
    42564256          else if (!strcmp(argv[i], "allocations"))
    42574257            val = make_stats_allocations;
     4258          else if (!strcmp(argv[i], "reallocations"))
     4259            val = make_stats_reallocations;
    42584260          else if (!strcmp(argv[i], "allocated"))
    42594261            val = make_stats_allocated;
    4260           else if (!strcmp(argv[i], "allocated_sum"))
    4261             val = make_stats_allocated_sum;
    42624262          else if (!strcmp(argv[i], "ht_lookups"))
    42634263            val = make_stats_ht_lookups;
     
    46394639  { STRING_SIZE_TUPLE("libpath"),       1,  2,  1,  func_os2_libpath},
    46404640#endif
    4641 #ifdef CONFIG_WITH_MAKE_STATS
     4641#if defined (CONFIG_WITH_MAKE_STATS) || defined (CONFIG_WITH_MINIMAL_STATS)
    46424642  { STRING_SIZE_TUPLE("make-stats"),    0,  0,  0,  func_make_stats},
    46434643#endif
  • trunk/src/kmk/make.h

    r1976 r1986  
    208208#ifdef CONFIG_WITH_MAKE_STATS
    209209extern long make_stats_allocations;
     210extern long make_stats_reallocations;
    210211extern unsigned long make_stats_allocated;
    211 extern unsigned long make_stats_allocated_sum;
    212212extern unsigned long make_stats_ht_lookups;
    213213extern unsigned long make_stats_ht_collisions;
     
    215215# ifdef __APPLE__
    216216#  include <malloc/malloc.h>
    217 #  define SIZE_OF_HEAP_BLOCK(ptr)   malloc_size(ptr)
     217#  define SIZE_OF_HEAP_BLOCK(ptr)   malloc_good_size(ptr)
    218218
    219219# elif defined(__linux__) /* glibc */
     
    228228#  define SIZE_OF_HEAP_BLOCK(ptr)   0
    229229#endif
    230 
    231 # if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP)
    232 #  define free xfree
    233 extern void xfree (void *);
    234 # endif
    235230
    236231# define MAKE_STATS_3(expr) do { expr; } while (0)
  • trunk/src/kmk/misc.c

    r1971 r1986  
    398398  if (result == 0)
    399399    fatal (NILF, _("virtual memory exhausted"));
     400
    400401#ifdef CONFIG_WITH_MAKE_STATS
    401402  make_stats_allocations++;
    402403  if (make_expensive_statistics)
    403     {
    404       unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result);
    405       make_stats_allocated += actual_size;
    406       make_stats_allocated_sum += actual_size;
    407     }
     404    make_stats_allocated += SIZE_OF_HEAP_BLOCK (result);
     405  else
     406    make_stats_allocated += size;
    408407#endif
    409408  return result;
     
    417416#ifdef CONFIG_WITH_MAKE_STATS
    418417  if (make_expensive_statistics && ptr != NULL)
    419     {
    420       unsigned int actual_size = SIZE_OF_HEAP_BLOCK (ptr);
    421       make_stats_allocated -= actual_size;
    422       make_stats_allocated_sum -= actual_size;
    423     }
     418    make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr);
     419  if (ptr)
     420    make_stats_reallocations++;
     421  else
     422    make_stats_allocations++;
    424423#endif
    425424
     
    430429  if (result == 0)
    431430    fatal (NILF, _("virtual memory exhausted"));
     431
    432432#ifdef CONFIG_WITH_MAKE_STATS
    433   if (!ptr)
    434     make_stats_allocations++;
    435433  if (make_expensive_statistics)
    436     {
    437       unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result);
    438       make_stats_allocated += actual_size;
    439       make_stats_allocated_sum += actual_size;
    440     }
     434    make_stats_allocated += SIZE_OF_HEAP_BLOCK (result);
     435  else
     436    make_stats_allocated += size;
    441437#endif
    442438  return result;
     
    461457  make_stats_allocations++;
    462458  if (make_expensive_statistics)
    463     {
    464       unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result);
    465       make_stats_allocated += actual_size;
    466       make_stats_allocated_sum += actual_size;
    467     }
     459    make_stats_allocated += SIZE_OF_HEAP_BLOCK (result);
     460  else
     461    make_stats_allocated += strlen (ptr) + 1;
    468462#endif
    469463#ifdef HAVE_STRDUP
     
    11651159}
    11661160
    1167 #if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP)
    1168 #undef free
    1169 void xfree(void *ptr)
    1170 {
    1171   if (ptr)
    1172     {
    1173       make_stats_allocations--;
    1174       if (make_expensive_statistics)
    1175         make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr);
    1176       free (ptr);
    1177     }
    1178 }
    1179 #endif
    1180 
    1181 
    11821161#ifdef CONFIG_WITH_ALLOC_CACHES
    11831162
     
    14031382# endif /* __GLIBC__ */
    14041383
     1384# ifdef CONFIG_WITH_MAKE_STATS
     1385  printf(_("#            %lu malloc calls,  %lu realloc calls\n"),
     1386         make_stats_allocations, make_stats_reallocations);
     1387  printf(_("#            %lu MBs alloc sum, not counting freed, add pinch of salt\n"), /* XXX: better wording */
     1388         make_stats_allocated / (1024*1024));
     1389# endif
     1390
    14051391  /* XXX: windows */
    14061392}
Note: See TracChangeset for help on using the changeset viewer.

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