VirtualBox

Changeset 1535 in kBuild


Ignore:
Timestamp:
Apr 20, 2008 10:19:40 PM (17 years ago)
Author:
bird
Message:

Made the allocated and allocated-sum optional as they made xmalloc and xfree very expensive. New argument: --statistics / KMK_OPTS_STATISTICS=[1|0]

Location:
trunk/src/kmk
Files:
3 edited

Legend:

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

    r1526 r1535  
    311311    4 = high / nice -10;
    312312    5 = realtime / nice -19; */
     313
    313314int process_priority = 0;
    314315
    315316/* Process affinity mask; 0 means any CPU. */
     317
    316318int process_affinity = 0;
    317319#endif /* KMK */
     320
     321#ifdef CONFIG_WITH_MAKE_STATS
     322/* When set, we'll gather expensive statistics like for the heap. */
     323
     324int make_expensive_statistics = 0;
     325#endif
    318326
    319327
     
    406414  --pretty-command-printing   Makes the command echo easier to read.\n"),
    407415#endif
     416#ifdef CONFIG_WITH_MAKE_STATS
     417    N_("\
     418  --statistics                Gather extra statistics for $(make-stats ).\n"),
     419#endif
    408420    NULL
    409421  };
     
    461473    { 'S', flag_off, &keep_going_flag, 1, 1, 0, 0, &default_keep_going_flag,
    462474      "no-keep-going" },
     475#ifdef KMK
     476    { CHAR_MAX+14, flag, (char *) &make_expensive_statistics, 1, 1, 1, 0, 0,
     477       "statistics" },
     478#endif
    463479    { 't', flag, &touch_flag, 1, 1, 1, 0, 0, "touch" },
    464480    { 'v', flag, &print_version_flag, 1, 1, 0, 0, 0, "version" },
     
    33493365    char val[32];
    33503366    sprintf (val, "%u", job_slots);
    3351     define_variable ("KMK_OPTS_JOBS", sizeof("KMK_OPTS_JOBS") - 1, 
     3367    define_variable ("KMK_OPTS_JOBS", sizeof("KMK_OPTS_JOBS") - 1,
    33523368                     val, o_default, 1);
    3353     define_variable ("KMK_OPTS_KEEP_GOING", sizeof("KMK_OPTS_KEEP_GOING") - 1, 
     3369    define_variable ("KMK_OPTS_KEEP_GOING", sizeof("KMK_OPTS_KEEP_GOING") - 1,
    33543370                     keep_going_flag ? "1" : "0", o_default, 1);
    3355     define_variable ("KMK_OPTS_JUST_PRINT", sizeof("KMK_OPTS_JUST_PRINT") - 1, 
     3371    define_variable ("KMK_OPTS_JUST_PRINT", sizeof("KMK_OPTS_JUST_PRINT") - 1,
    33563372                     just_print_flag ? "1" : "0", o_default, 1);
    3357     define_variable ("KMK_OPTS_PRETTY_COMMAND_PRINTING", sizeof("KMK_OPTS_PRETTY_COMMAND_PRINTING") - 1, 
     3373    define_variable ("KMK_OPTS_PRETTY_COMMAND_PRINTING", sizeof("KMK_OPTS_PRETTY_COMMAND_PRINTING") - 1,
    33583374                     pretty_command_printing ? "1" : "0", o_default, 1);
    33593375    sprintf (val, "%u", process_priority);
    3360     define_variable ("KMK_OPTS_PRORITY", sizeof("KMK_OPTS_PRORITY") - 1, 
     3376    define_variable ("KMK_OPTS_PRORITY", sizeof("KMK_OPTS_PRORITY") - 1,
    33613377                     val, o_default, 1);
    33623378    sprintf (val, "%u", process_affinity);
    3363     define_variable ("KMK_OPTS_AFFINITY", sizeof("KMK_OPTS_AFFINITY") - 1, 
     3379    define_variable ("KMK_OPTS_AFFINITY", sizeof("KMK_OPTS_AFFINITY") - 1,
    33643380                     val, o_default, 1);
     3381    define_variable ("KMK_OPTS_STATISTICS", sizeof("KMK_OPTS_STATISTICS") - 1,
     3382                     make_expensive_statistics ? "1" : "0", o_default, 1);
    33653383  }
    33663384#endif
     
    34003418%s Copyright (c) 1998  Todd C. Miller <[email protected]>\n\
    34013419%s\n",
    3402           precede, KBUILD_VERSION_MAJOR, KBUILD_VERSION_MINOR, 
     3420          precede, KBUILD_VERSION_MAJOR, KBUILD_VERSION_MINOR,
    34033421          KBUILD_VERSION_PATCH, KBUILD_SVN_REV,
    34043422          precede, version_string,
    3405           precede, precede, precede, precede, precede, precede, 
     3423          precede, precede, precede, precede, precede, precede,
    34063424          precede, precede);
    34073425#else
  • trunk/src/kmk/make.h

    r1438 r1535  
    503503extern int pretty_command_printing;
    504504#endif
     505#ifdef CONFIG_WITH_MAKE_STATS
     506extern int make_expensive_statistics;
     507#endif
     508
    505509
    506510/* can we run commands via 'sh -c xxx' or must we use batch files? */
  • trunk/src/kmk/misc.c

    r1469 r1535  
    363363#ifdef CONFIG_WITH_MAKE_STATS
    364364  make_stats_allocations++;
    365   make_stats_allocated += SIZE_OF_HEAP_BLOCK (result);
    366   make_stats_allocated_sum += SIZE_OF_HEAP_BLOCK (result);
     365  if (make_expensive_statistics)
     366    {
     367      unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result);
     368      make_stats_allocated += actual_size;
     369      make_stats_allocated_sum += actual_size;
     370    }
    367371#endif
    368372  return result;
     
    375379  void *result;
    376380#ifdef CONFIG_WITH_MAKE_STATS
    377   if (ptr != NULL)
    378     {
    379       make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr);
    380       make_stats_allocated_sum -= SIZE_OF_HEAP_BLOCK (ptr);
     381  if (make_expensive_statistics && ptr != NULL)
     382    {
     383      unsigned int actual_size = SIZE_OF_HEAP_BLOCK (ptr);
     384      make_stats_allocated -= actual_size;
     385      make_stats_allocated_sum -= actual_size;
    381386    }
    382387#endif
     
    389394    fatal (NILF, _("virtual memory exhausted"));
    390395#ifdef CONFIG_WITH_MAKE_STATS
    391   make_stats_allocated += SIZE_OF_HEAP_BLOCK (result);
    392   make_stats_allocated_sum += SIZE_OF_HEAP_BLOCK (result);
     396  if (!ptr)
     397    make_stats_allocations++;
     398  if (make_expensive_statistics)
     399    {
     400      unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result);
     401      make_stats_allocated += actual_size;
     402      make_stats_allocated_sum += actual_size;
     403    }
    393404#endif
    394405  return result;
     
    412423#ifdef CONFIG_WITH_MAKE_STATS
    413424  make_stats_allocations++;
    414   make_stats_allocated += SIZE_OF_HEAP_BLOCK (result);
    415   make_stats_allocated_sum += SIZE_OF_HEAP_BLOCK (result);
     425  if (make_expensive_statistics)
     426    {
     427      unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result);
     428      make_stats_allocated += actual_size;
     429      make_stats_allocated_sum += actual_size;
     430    }
    416431#endif
    417432#ifdef HAVE_STRDUP
     
    950965void xfree(void *ptr)
    951966{
    952   if (ptr) 
     967  if (ptr)
    953968    {
    954969      make_stats_allocations--;
    955       make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr);
     970      if (make_expensive_statistics)
     971        make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr);
    956972      free (ptr);
    957973    }
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