Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @ 1888:a7214d79fcf1
6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
Summary: Deprecated HandlePromotionFailure, removing the ability to turn off that feature, did away with one epoch look-ahead when deciding if a scavenge is likely to fail, relying on current data.
Reviewed-by: jmasa, johnc, poonam
author | ysr |
---|---|
date | Sat, 23 Oct 2010 23:03:49 -0700 |
parents | c99c53f07c14 |
children | f95d63e2154a |
comparison
equal
deleted
inserted
replaced
1887:cd3ef3fd20dd | 1888:a7214d79fcf1 |
---|---|
352 // the padded average size of the promotion for each | 352 // the padded average size of the promotion for each |
353 // young generation collection. | 353 // young generation collection. |
354 double CMSStats::time_until_cms_gen_full() const { | 354 double CMSStats::time_until_cms_gen_full() const { |
355 size_t cms_free = _cms_gen->cmsSpace()->free(); | 355 size_t cms_free = _cms_gen->cmsSpace()->free(); |
356 GenCollectedHeap* gch = GenCollectedHeap::heap(); | 356 GenCollectedHeap* gch = GenCollectedHeap::heap(); |
357 size_t expected_promotion = gch->get_gen(0)->capacity(); | 357 size_t expected_promotion = MIN2(gch->get_gen(0)->capacity(), |
358 if (HandlePromotionFailure) { | 358 (size_t) _cms_gen->gc_stats()->avg_promoted()->padded_average()); |
359 expected_promotion = MIN2( | |
360 (size_t) _cms_gen->gc_stats()->avg_promoted()->padded_average(), | |
361 expected_promotion); | |
362 } | |
363 if (cms_free > expected_promotion) { | 359 if (cms_free > expected_promotion) { |
364 // Start a cms collection if there isn't enough space to promote | 360 // Start a cms collection if there isn't enough space to promote |
365 // for the next minor collection. Use the padded average as | 361 // for the next minor collection. Use the padded average as |
366 // a safety factor. | 362 // a safety factor. |
367 cms_free -= expected_promotion; | 363 cms_free -= expected_promotion; |
863 | 859 |
864 size_t ConcurrentMarkSweepGeneration::max_available() const { | 860 size_t ConcurrentMarkSweepGeneration::max_available() const { |
865 return free() + _virtual_space.uncommitted_size(); | 861 return free() + _virtual_space.uncommitted_size(); |
866 } | 862 } |
867 | 863 |
868 bool ConcurrentMarkSweepGeneration::promotion_attempt_is_safe( | 864 bool ConcurrentMarkSweepGeneration::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const { |
869 size_t max_promotion_in_bytes, | 865 size_t available = max_available(); |
870 bool younger_handles_promotion_failure) const { | 866 size_t av_promo = (size_t)gc_stats()->avg_promoted()->padded_average(); |
871 | 867 bool res = (available >= av_promo) || (available >= max_promotion_in_bytes); |
872 // This is the most conservative test. Full promotion is | 868 if (PrintGC && Verbose) { |
873 // guaranteed if this is used. The multiplicative factor is to | 869 gclog_or_tty->print_cr( |
874 // account for the worst case "dilatation". | 870 "CMS: promo attempt is%s safe: available("SIZE_FORMAT") %s av_promo("SIZE_FORMAT")," |
875 double adjusted_max_promo_bytes = _dilatation_factor * max_promotion_in_bytes; | 871 "max_promo("SIZE_FORMAT")", |
876 if (adjusted_max_promo_bytes > (double)max_uintx) { // larger than size_t | 872 res? "":" not", available, res? ">=":"<", |
877 adjusted_max_promo_bytes = (double)max_uintx; | 873 av_promo, max_promotion_in_bytes); |
878 } | 874 } |
879 bool result = (max_contiguous_available() >= (size_t)adjusted_max_promo_bytes); | 875 return res; |
880 | |
881 if (younger_handles_promotion_failure && !result) { | |
882 // Full promotion is not guaranteed because fragmentation | |
883 // of the cms generation can prevent the full promotion. | |
884 result = (max_available() >= (size_t)adjusted_max_promo_bytes); | |
885 | |
886 if (!result) { | |
887 // With promotion failure handling the test for the ability | |
888 // to support the promotion does not have to be guaranteed. | |
889 // Use an average of the amount promoted. | |
890 result = max_available() >= (size_t) | |
891 gc_stats()->avg_promoted()->padded_average(); | |
892 if (PrintGC && Verbose && result) { | |
893 gclog_or_tty->print_cr( | |
894 "\nConcurrentMarkSweepGeneration::promotion_attempt_is_safe" | |
895 " max_available: " SIZE_FORMAT | |
896 " avg_promoted: " SIZE_FORMAT, | |
897 max_available(), (size_t) | |
898 gc_stats()->avg_promoted()->padded_average()); | |
899 } | |
900 } else { | |
901 if (PrintGC && Verbose) { | |
902 gclog_or_tty->print_cr( | |
903 "\nConcurrentMarkSweepGeneration::promotion_attempt_is_safe" | |
904 " max_available: " SIZE_FORMAT | |
905 " adj_max_promo_bytes: " SIZE_FORMAT, | |
906 max_available(), (size_t)adjusted_max_promo_bytes); | |
907 } | |
908 } | |
909 } else { | |
910 if (PrintGC && Verbose) { | |
911 gclog_or_tty->print_cr( | |
912 "\nConcurrentMarkSweepGeneration::promotion_attempt_is_safe" | |
913 " contiguous_available: " SIZE_FORMAT | |
914 " adj_max_promo_bytes: " SIZE_FORMAT, | |
915 max_contiguous_available(), (size_t)adjusted_max_promo_bytes); | |
916 } | |
917 } | |
918 return result; | |
919 } | 876 } |
920 | 877 |
921 // At a promotion failure dump information on block layout in heap | 878 // At a promotion failure dump information on block layout in heap |
922 // (cms old generation). | 879 // (cms old generation). |
923 void ConcurrentMarkSweepGeneration::promotion_failure_occurred() { | 880 void ConcurrentMarkSweepGeneration::promotion_failure_occurred() { |
6089 // under the freelistLock (as is the check for whether to | 6046 // under the freelistLock (as is the check for whether to |
6090 // allocate-live and whether to dirty the mod-union table). | 6047 // allocate-live and whether to dirty the mod-union table). |
6091 assert(_collectorState == Resizing, "Change of collector state to" | 6048 assert(_collectorState == Resizing, "Change of collector state to" |
6092 " Resizing must be done under the freelistLocks (plural)"); | 6049 " Resizing must be done under the freelistLocks (plural)"); |
6093 | 6050 |
6094 // Now that sweeping has been completed, if the GCH's | 6051 // Now that sweeping has been completed, we clear |
6095 // incremental_collection_will_fail flag is set, clear it, | 6052 // the incremental_collection_failed flag, |
6096 // thus inviting a younger gen collection to promote into | 6053 // thus inviting a younger gen collection to promote into |
6097 // this generation. If such a promotion may still fail, | 6054 // this generation. If such a promotion may still fail, |
6098 // the flag will be set again when a young collection is | 6055 // the flag will be set again when a young collection is |
6099 // attempted. | 6056 // attempted. |
6100 // I think the incremental_collection_will_fail flag's use | |
6101 // is specific to a 2 generation collection policy, so i'll | |
6102 // assert that that's the configuration we are operating within. | |
6103 // The use of the flag can and should be generalized appropriately | |
6104 // in the future to deal with a general n-generation system. | |
6105 | |
6106 GenCollectedHeap* gch = GenCollectedHeap::heap(); | 6057 GenCollectedHeap* gch = GenCollectedHeap::heap(); |
6107 assert(gch->collector_policy()->is_two_generation_policy(), | 6058 gch->clear_incremental_collection_failed(); // Worth retrying as fresh space may have been freed up |
6108 "Resetting of incremental_collection_will_fail flag" | |
6109 " may be incorrect otherwise"); | |
6110 gch->clear_incremental_collection_will_fail(); | |
6111 gch->update_full_collections_completed(_collection_count_start); | 6059 gch->update_full_collections_completed(_collection_count_start); |
6112 } | 6060 } |
6113 | 6061 |
6114 // FIX ME!!! Looks like this belongs in CFLSpace, with | 6062 // FIX ME!!! Looks like this belongs in CFLSpace, with |
6115 // CMSGen merely delegating to it. | 6063 // CMSGen merely delegating to it. |