/[cmucl]/src/lisp/gencgc.c
ViewVC logotype

Diff of /src/lisp/gencgc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.95.2.1.2.5 by rtoy, Sat May 2 01:53:00 2009 UTC revision 1.95.2.1.2.6 by rtoy, Mon May 4 21:07:11 2009 UTC
# Line 1611  int consecutive_large_alloc_limit = 10; Line 1611  int consecutive_large_alloc_limit = 10;
1611   */   */
1612  int abandon_boxed_region_count = 0;  int abandon_boxed_region_count = 0;
1613  int abandon_unboxed_region_count = 0;  int abandon_unboxed_region_count = 0;
1614    int saved_and_boxed_region_differ = 0;
1615    
1616    
1617  /*  /*
# Line 1623  gc_alloc(int nbytes) Line 1624  gc_alloc(int nbytes)
1624  {  {
1625      char *new_free_pointer;      char *new_free_pointer;
1626      static int consecutive_large_alloc = 0;      static int consecutive_large_alloc = 0;
1627        static struct alloc_region *saved_boxed = NULL;
1628    
1629  #if 0  #if 0
1630      fprintf(stderr, "gc_alloc %d\n", nbytes);      fprintf(stderr, "gc_alloc %d\n", nbytes);
# Line 1647  gc_alloc(int nbytes) Line 1648  gc_alloc(int nbytes)
1648          }          }
1649    
1650          consecutive_large_alloc = 0;          consecutive_large_alloc = 0;
1651            if (saved_boxed) {
1652                free(saved_boxed);
1653                saved_boxed = NULL;
1654            }
1655    
1656          return (void *) new_obj;          return (void *) new_obj;
1657      }      }
1658    
# Line 1676  gc_alloc(int nbytes) Line 1682  gc_alloc(int nbytes)
1682       * the free space left in the region is too small.  This helps GC       * the free space left in the region is too small.  This helps GC
1683       * so we don't have to copy this object again.       * so we don't have to copy this object again.
1684       *       *
1685       * Heuristic: If       * Heuristic: If we do too many consecutive large allocations
1686       * we do too many consecutive large allocations because the       * because the current region has some space left, we give up and
1687       * current region has some space left, we give up and abandon the       * abandon the region. This will prevent the bad scenario above
1688       * region. This will prevent the bad scenario above from killing       * from killing gc allocation performance.
      * gc allocation performance.  
1689       *       *
1690       */       */
1691      if ((boxed_region.end_addr - boxed_region.free_pointer > region_empty_threshold)      if (((boxed_region.end_addr - boxed_region.free_pointer > region_empty_threshold)
1692          || (nbytes >= large_object_size)           || (nbytes >= large_object_size))
1693          || (consecutive_large_alloc < consecutive_large_alloc_limit)) {          && (consecutive_large_alloc < consecutive_large_alloc_limit)) {
1694          ++consecutive_large_alloc;          if (nbytes < large_object_size) {
1695                /* Large objects don't count */
1696                if (saved_boxed) {
1697                    /* Is the saved region the same as the current region?
1698                     * If so, update the counter.  If not, that means we
1699                     * did some other allocation, so reset the counter and region
1700                     */
1701                    if (memcmp(saved_boxed, &boxed_region, sizeof(*saved_boxed)) == 0) {
1702                        ++consecutive_large_alloc;
1703                    } else {
1704                        consecutive_large_alloc = 0;
1705    #if 0
1706                        fprintf(stderr, "saved and current boxed regions are different!  Resetting!\n");
1707    #endif
1708                        ++saved_and_boxed_region_differ;
1709    
1710                        memcpy(saved_boxed, &boxed_region, sizeof(*saved_boxed));
1711                    }
1712                } else {
1713                    /* No saved region, so copy it */
1714                    saved_boxed = (struct alloc_region *) malloc(sizeof(*saved_boxed));
1715                    memcpy(saved_boxed, &boxed_region, sizeof(*saved_boxed));
1716                    ++consecutive_large_alloc;
1717                }
1718            }
1719    
1720          return gc_alloc_large(nbytes, 0, &boxed_region);          return gc_alloc_large(nbytes, 0, &boxed_region);
1721      }      }
1722    
1723      consecutive_large_alloc = 0;      consecutive_large_alloc = 0;
1724      ++abandon_boxed_region_count;      ++abandon_boxed_region_count;
1725    
# Line 1721  gc_alloc(int nbytes) Line 1751  gc_alloc(int nbytes)
1751              gc_alloc_new_region(32, 0, &boxed_region);              gc_alloc_new_region(32, 0, &boxed_region);
1752          }          }
1753    
1754            if (saved_boxed) {
1755                free(saved_boxed);
1756                saved_boxed = NULL;
1757            }
1758    
1759          return (void *) new_obj;          return (void *) new_obj;
1760      }      }
1761    

Legend:
Removed from v.1.95.2.1.2.5  
changed lines
  Added in v.1.95.2.1.2.6

  ViewVC Help
Powered by ViewVC 1.1.5