VirtualBox

Changeset 2056 in kBuild


Ignore:
Timestamp:
Nov 4, 2008 3:25:19 AM (17 years ago)
Author:
bird
Message:

kmk: some MBs of memory during building by freeing up the chopped up command lines after we're done with them. (Code not perfect, but wtf., it saves me 7 MBs (out of 45), a bunch of faults and turns out to using less cpu time...)

Location:
trunk/src/kmk
Files:
6 edited

Legend:

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

    r2024 r2056  
    172172        CONFIG_WITH_RDONLY_VARIABLE_VALUE \
    173173        CONFIG_WITH_LAZY_DEPS_VARS \
     174        CONFIG_WITH_MEMORY_OPTIMIZATIONS \
    174175        \
    175176        KBUILD_HOST=\"$(KBUILD_TARGET)\" \
  • trunk/src/kmk/commands.h

    r2024 r2056  
    3333    int any_recurse;            /* Nonzero if any `lines_recurse' elt has */
    3434                                /* the COMMANDS_RECURSE bit set.  */
     35#ifdef CONFIG_WITH_MEMORY_OPTIMIZATIONS
     36    int refs;                   /* References.  */
     37#endif
    3538  };
    3639
  • trunk/src/kmk/default.c

    r1993 r2056  
    584584      if (f->cmds == 0)
    585585        {
     586#ifndef CONFIG_WITH_ALLOC_CACHES
    586587          f->cmds = xmalloc (sizeof (struct commands));
     588#else
     589          f->cmds = alloccache_alloc (&commands_cache);
     590#endif
    587591          f->cmds->fileinfo.filenm = 0;
    588592          f->cmds->commands = s[1];
    589593          f->cmds->command_lines = 0;
     594#ifdef CONFIG_WITH_MEMORY_OPTIMIZATIONS
     595          f->cmds->refs = 1000;
     596#endif
    590597        }
    591598    }
  • trunk/src/kmk/job.c

    r2001 r2056  
    944944    }
    945945
     946#ifdef CONFIG_WITH_MEMORY_OPTIMIZATIONS
     947  /* Free the chopped command lines for simple targets when
     948     there are no more active references to them.  */
     949
     950  child->file->cmds->refs--;
     951  if (   !child->file->intermediate
     952      && !child->file->pat_variables
     953      && child->file->cmds->refs == 0)
     954    {
     955      struct commands *cmds = child->file->cmds;
     956      unsigned int i;
     957
     958      for (i = 0; i < cmds->ncommand_lines; ++i)
     959        {
     960          free (cmds->command_lines[i]);
     961          cmds->command_lines[i] = 0;
     962        }
     963      free (cmds->command_lines);
     964      cmds->command_lines = 0;
     965      free (cmds->lines_flags);
     966      cmds->lines_flags = 0;
     967      cmds->ncommand_lines = 0;
     968    }
     969#endif /* CONFIG_WITH_MEMORY_OPTIMIZATIONS */
     970
    946971  free (child);
    947972}
     
    16821707  /* Chop the commands up into lines if they aren't already.  */
    16831708  chop_commands (cmds);
     1709#ifdef CONFIG_WITH_MEMORY_OPTIMIZATIONS
     1710  cmds->refs++; /* retain the chopped lines.  */
     1711#endif
    16841712
    16851713  /* Expand the command lines and store the results in LINES.  */
  • trunk/src/kmk/read.c

    r2041 r2056  
    25402540      cmds->commands = savestring (commands, commands_idx);
    25412541      cmds->command_lines = 0;
     2542#ifdef CONFIG_WITH_MEMORY_OPTIMIZATIONS
     2543      cmds->refs = 0;
     2544#endif
    25422545    }
    25432546  else
  • trunk/src/kmk/rule.c

    r1993 r2056  
    404404      r->cmds->commands = xstrdup (p->commands);
    405405      r->cmds->command_lines = 0;
     406#ifdef CONFIG_WITH_MEMORY_OPTIMIZATIONS
     407      r->cmds->refs = 1000;
     408#endif
    406409    }
    407410}
     
    489492  if (new_pattern_rule (r, override))
    490493    r->terminal = terminal;
     494#ifdef CONFIG_WITH_MEMORY_OPTIMIZATIONS
     495  commands->refs = 1000;
     496#endif
    491497}
    492498
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