@@ -633,10 +633,22 @@ static void update_major_slice_work(intnat howmuch,
633
633
634
634
my_alloc_count = dom_st -> allocated_words ;
635
635
my_alloc_direct_count = dom_st -> allocated_words_direct ;
636
- my_extra_count =
637
- (double )dom_st -> allocated_dependent_bytes /
638
- (double )caml_custom_get_max_major ();
639
- if (my_extra_count > 1.0 ) my_extra_count = 1.0 ;
636
+ {
637
+ /* The major ratio is a percentage relative to the major heap size.
638
+ A complete GC cycle will be done every time 2/3 of that much
639
+ memory is allocated for blocks in the major heap. Assuming
640
+ constant allocation and deallocation rates, this means there are
641
+ at most [M/100 * major-heap-size] bytes of floating garbage at
642
+ any time. The reason for a factor of 2/3 (or 1.5) is, roughly
643
+ speaking, because the major GC takes 1.5 cycles (previous cycle +
644
+ marking phase) before it starts to deallocate dead blocks
645
+ allocated during the previous cycle. [heap_size / 150] is really
646
+ [heap_size * (2/3) / 100] (but faster). */
647
+ double max_major =
648
+ caml_heap_size (Caml_state -> shared_heap ) / 150 * caml_custom_major_ratio ;
649
+ my_extra_count = (double )dom_st -> allocated_dependent_bytes / max_major ;
650
+ if (my_extra_count > 1.0 ) my_extra_count = 1.0 ;
651
+ }
640
652
dom_st -> stat_major_words += dom_st -> allocated_words ;
641
653
dom_st -> allocated_words = 0 ;
642
654
dom_st -> allocated_words_direct = 0 ;
0 commit comments