[pypy-svn] r31644 - pypy/dist/pypy/rpython/memory

ac at codespeak.net ac at codespeak.net
Fri Aug 25 17:06:56 CEST 2006


Author: ac
Date: Fri Aug 25 17:06:55 2006
New Revision: 31644

Modified:
   pypy/dist/pypy/rpython/memory/gc.py
Log:
Fix division by zero problem.



Modified: pypy/dist/pypy/rpython/memory/gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gc.py	(original)
+++ pypy/dist/pypy/rpython/memory/gc.py	Fri Aug 25 17:06:55 2006
@@ -350,18 +350,13 @@
         compute_time = start_time - self.prev_collect_end_time
         collect_time = end_time - start_time
 
+        garbage_collected = old_malloced - (curr_heap_size - self.heap_usage)
 
-
-
-        collect_time_fraction = collect_time / compute_time
-        old_heapsize = self.heap_usage
-        garbage_generated = old_malloced - (curr_heap_size - old_heapsize)
-        garbage_fraction = float(garbage_generated) / float(curr_heap_size)
-
-
-        if collect_time_fraction > 0.02 * garbage_fraction:
+        if (collect_time * curr_heap_size >
+            0.02 * garbage_collected * compute_time): 
             self.bytes_malloced_threshold += self.bytes_malloced_threshold / 2
-        if collect_time_fraction < 0.005 * garbage_fraction:
+        if (collect_time * curr_heap_size <
+            0.005 * garbage_collected * compute_time):
             self.bytes_malloced_threshold /= 2
 
         # Use atleast as much memory as current live objects.
@@ -390,11 +385,11 @@
                              "  total time spent collecting:       ",
                              self.total_collection_time, "seconds")
             llop.debug_print(lltype.Void,
-                             "  collecting time fraction:          ",
-                             collect_time_fraction)
+                             "  collecting time:                   ",
+                             collect_time)
             llop.debug_print(lltype.Void,
-                             "  garbage fraction:                  ",
-                             garbage_fraction)
+                             "  computing time:                    ",
+                             collect_time)
             llop.debug_print(lltype.Void,
                              "  new threshold:                     ",
                              self.bytes_malloced_threshold)



More information about the Pypy-commit mailing list