[BACK]Return to jemalloc.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / stdlib

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/lib/libc/stdlib/jemalloc.c between version 1.19.4.1 and 1.22

version 1.19.4.1, 2010/03/13 00:53:32 version 1.22, 2011/02/26 23:27:49
Line 319  __strerror_r(int e, char *s, size_t l)
Line 319  __strerror_r(int e, char *s, size_t l)
 #define SMALL_MAX_DEFAULT       (1 << SMALL_MAX_2POW_DEFAULT)  #define SMALL_MAX_DEFAULT       (1 << SMALL_MAX_2POW_DEFAULT)
   
 /*  /*
  * Maximum desired run header overhead.  Runs are sized as small as possible   * RUN_MAX_OVRHD indicates maximum desired run header overhead.  Runs are sized
  * such that this setting is still honored, without violating other constraints.   * as small as possible such that this setting is still honored, without
  * The goal is to make runs as small as possible without exceeding a per run   * violating other constraints.  The goal is to make runs as small as possible
  * external fragmentation threshold.   * without exceeding a per run external fragmentation threshold.
  *   *
  * Note that it is possible to set this low enough that it cannot be honored   * We use binary fixed point math for overhead computations, where the binary
  * for some/all object sizes, since there is one bit of header overhead per   * point is implicitly RUN_BFP bits to the left.
  * object (plus a constant).  In such cases, this constraint is relaxed.  
  *   *
  * RUN_MAX_OVRHD_RELAX specifies the maximum number of bits per region of   * Note that it is possible to set RUN_MAX_OVRHD low enough that it cannot be
  * overhead for which RUN_MAX_OVRHD is relaxed.   * honored for some/all object sizes, since there is one bit of header overhead
    * per object (plus a constant).  This constraint is relaxed (ignored) for runs
    * that are so small that the per-region overhead is greater than:
    *
    *   (RUN_MAX_OVRHD / (reg_size << (3+RUN_BFP))
  */   */
 #define RUN_MAX_OVRHD           0.015  #define RUN_BFP                 12
 #define RUN_MAX_OVRHD_RELAX     1.5  /*                              \/   Implicit binary fixed point. */
   #define RUN_MAX_OVRHD           0x0000003dU
   #define RUN_MAX_OVRHD_RELAX     0x00001800U
   
 /* Put a cap on small object run size.  This overrides RUN_MAX_OVRHD. */  /* Put a cap on small object run size.  This overrides RUN_MAX_OVRHD. */
 #define RUN_MAX_SMALL_2POW      15  #define RUN_MAX_SMALL_2POW      15
Line 1029  base_pages_alloc(size_t minsize)
Line 1034  base_pages_alloc(size_t minsize)
                          */                           */
                         incr = (intptr_t)chunksize                          incr = (intptr_t)chunksize
                             - (intptr_t)CHUNK_ADDR2OFFSET(brk_cur);                              - (intptr_t)CHUNK_ADDR2OFFSET(brk_cur);
                         if (incr < minsize)                          assert(incr >= 0);
                           if ((size_t)incr < minsize)
                                 incr += csize;                                  incr += csize;
   
                         brk_prev = sbrk(incr);                          brk_prev = sbrk(incr);
Line 1364  chunk_alloc(size_t size)
Line 1370  chunk_alloc(size_t size)
                          */                           */
                         incr = (intptr_t)size                          incr = (intptr_t)size
                             - (intptr_t)CHUNK_ADDR2OFFSET(brk_cur);                              - (intptr_t)CHUNK_ADDR2OFFSET(brk_cur);
                         if (incr == size) {                          if (incr == (intptr_t)size) {
                                 ret = brk_cur;                                  ret = brk_cur;
                         } else {                          } else {
                                 ret = (void *)((intptr_t)brk_cur + incr);                                  ret = (void *)((intptr_t)brk_cur + incr);
Line 2142  arena_bin_run_size_calc(arena_bin_t *bin
Line 2148  arena_bin_run_size_calc(arena_bin_t *bin
         size_t try_run_size, good_run_size;          size_t try_run_size, good_run_size;
         unsigned good_nregs, good_mask_nelms, good_reg0_offset;          unsigned good_nregs, good_mask_nelms, good_reg0_offset;
         unsigned try_nregs, try_mask_nelms, try_reg0_offset;          unsigned try_nregs, try_mask_nelms, try_reg0_offset;
         float max_ovrhd = RUN_MAX_OVRHD;  
   
         assert(min_run_size >= pagesize);          assert(min_run_size >= pagesize);
         assert(min_run_size <= arena_maxclass);          assert(min_run_size <= arena_maxclass);
Line 2160  arena_bin_run_size_calc(arena_bin_t *bin
Line 2165  arena_bin_run_size_calc(arena_bin_t *bin
          */           */
         try_run_size = min_run_size;          try_run_size = min_run_size;
         try_nregs = (unsigned)(((try_run_size - sizeof(arena_run_t)) /          try_nregs = (unsigned)(((try_run_size - sizeof(arena_run_t)) /
             bin->reg_size) + 1); /* Counter-act the first line of the loop. */              bin->reg_size) + 1); /* Counter-act try_nregs-- in loop. */
         do {          do {
                 try_nregs--;                  try_nregs--;
                 try_mask_nelms = (try_nregs >> (SIZEOF_INT_2POW + 3)) +                  try_mask_nelms = (try_nregs >> (SIZEOF_INT_2POW + 3)) +
Line 2194  arena_bin_run_size_calc(arena_bin_t *bin
Line 2199  arena_bin_run_size_calc(arena_bin_t *bin
                 } while (sizeof(arena_run_t) + (sizeof(unsigned) *                  } while (sizeof(arena_run_t) + (sizeof(unsigned) *
                     (try_mask_nelms - 1)) > try_reg0_offset);                      (try_mask_nelms - 1)) > try_reg0_offset);
         } while (try_run_size <= arena_maxclass && try_run_size <= RUN_MAX_SMALL          } while (try_run_size <= arena_maxclass && try_run_size <= RUN_MAX_SMALL
             && max_ovrhd > RUN_MAX_OVRHD_RELAX / ((float)(bin->reg_size << 3))              && RUN_MAX_OVRHD * (bin->reg_size << 3) > RUN_MAX_OVRHD_RELAX
             && ((float)(try_reg0_offset)) / ((float)(try_run_size)) >              && (try_reg0_offset << RUN_BFP) > RUN_MAX_OVRHD * try_run_size);
             max_ovrhd);  
   
         assert(sizeof(arena_run_t) + (sizeof(unsigned) * (good_mask_nelms - 1))          assert(sizeof(arena_run_t) + (sizeof(unsigned) * (good_mask_nelms - 1))
             <= good_reg0_offset);              <= good_reg0_offset);
Line 3443  malloc_init_hard(void)
Line 3447  malloc_init_hard(void)
                                         opt_chunk_2pow--;                                          opt_chunk_2pow--;
                                 break;                                  break;
                         case 'K':                          case 'K':
                                 /*                                  if (opt_chunk_2pow + 1 <
                                  * There must be fewer pages in a chunk than                                      (int)(sizeof(size_t) << 3))
                                  * can be recorded by the pos field of  
                                  * arena_chunk_map_t, in order to make POS_FREE  
                                  * special.  
                                  */  
                                 if (opt_chunk_2pow - pagesize_2pow  
                                     < (sizeof(uint32_t) << 3) - 1)  
                                         opt_chunk_2pow++;                                          opt_chunk_2pow++;
                                 break;                                  break;
                         case 'n':                          case 'n':

Legend:
Removed from v.1.19.4.1  
changed lines
  Added in v.1.22

CVSweb <webmaster@jp.NetBSD.org>