# HG changeset patch # User tschatzl # Date 1430987562 -7200 # Node ID 23e6e981e89c93be34cf125112fd9e60ae4ecf6f # Parent 12f312d694cd945e5b636daac71b53f6d4ad3276 8079556: BACKOUT - Determining the desired PLAB size adjusts to the the number of threads at the wrong place Reviewed-by: jwilhelm, brutisso diff -r 12f312d694cd -r 23e6e981e89c hotspot/src/share/vm/gc_implementation/g1/g1Allocator.cpp --- a/hotspot/src/share/vm/gc_implementation/g1/g1Allocator.cpp Wed Apr 29 15:12:33 2015 +0300 +++ b/hotspot/src/share/vm/gc_implementation/g1/g1Allocator.cpp Thu May 07 10:32:42 2015 +0200 @@ -83,7 +83,7 @@ &_retained_old_gc_alloc_region); } -void G1DefaultAllocator::release_gc_alloc_regions(EvacuationInfo& evacuation_info) { +void G1DefaultAllocator::release_gc_alloc_regions(uint no_of_gc_workers, EvacuationInfo& evacuation_info) { AllocationContext_t context = AllocationContext::current(); evacuation_info.set_allocation_regions(survivor_gc_alloc_region(context)->count() + old_gc_alloc_region(context)->count()); @@ -99,8 +99,8 @@ } if (ResizePLAB) { - _g1h->alloc_buffer_stats(InCSetState::Young)->adjust_desired_plab_sz(); - _g1h->alloc_buffer_stats(InCSetState::Old)->adjust_desired_plab_sz(); + _g1h->alloc_buffer_stats(InCSetState::Young)->adjust_desired_plab_sz(no_of_gc_workers); + _g1h->alloc_buffer_stats(InCSetState::Old)->adjust_desired_plab_sz(no_of_gc_workers); } } diff -r 12f312d694cd -r 23e6e981e89c hotspot/src/share/vm/gc_implementation/g1/g1Allocator.hpp --- a/hotspot/src/share/vm/gc_implementation/g1/g1Allocator.hpp Wed Apr 29 15:12:33 2015 +0300 +++ b/hotspot/src/share/vm/gc_implementation/g1/g1Allocator.hpp Thu May 07 10:32:42 2015 +0200 @@ -53,7 +53,7 @@ virtual void release_mutator_alloc_region() = 0; virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0; - virtual void release_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0; + virtual void release_gc_alloc_regions(uint no_of_gc_workers, EvacuationInfo& evacuation_info) = 0; virtual void abandon_gc_alloc_regions() = 0; virtual MutatorAllocRegion* mutator_alloc_region(AllocationContext_t context) = 0; @@ -114,7 +114,7 @@ virtual void release_mutator_alloc_region(); virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info); - virtual void release_gc_alloc_regions(EvacuationInfo& evacuation_info); + virtual void release_gc_alloc_regions(uint no_of_gc_workers, EvacuationInfo& evacuation_info); virtual void abandon_gc_alloc_regions(); virtual bool is_retained_old_region(HeapRegion* hr) { diff -r 12f312d694cd -r 23e6e981e89c hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Apr 29 15:12:33 2015 +0300 +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu May 07 10:32:42 2015 +0200 @@ -5439,7 +5439,7 @@ phase_times->record_string_dedup_fixup_time(fixup_time_ms); } - _allocator->release_gc_alloc_regions(evacuation_info); + _allocator->release_gc_alloc_regions(n_workers, evacuation_info); g1_rem_set()->cleanup_after_oops_into_collection_set_do(); // Reset and re-enable the hot card cache. diff -r 12f312d694cd -r 23e6e981e89c hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Wed Apr 29 15:12:33 2015 +0300 +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Thu May 07 10:32:42 2015 +0200 @@ -276,7 +276,7 @@ void init_gc_alloc_regions(EvacuationInfo& evacuation_info); // It releases the GC alloc regions at the end of a GC. - void release_gc_alloc_regions(EvacuationInfo& evacuation_info); + void release_gc_alloc_regions(uint no_of_gc_workers, EvacuationInfo& evacuation_info); // It does any cleanup that needs to be done on the GC alloc regions // before a Full GC. diff -r 12f312d694cd -r 23e6e981e89c hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp Wed Apr 29 15:12:33 2015 +0300 +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp Thu May 07 10:32:42 2015 +0200 @@ -48,7 +48,7 @@ } size_t G1CollectedHeap::desired_plab_sz(InCSetState dest) { - size_t gclab_word_size = alloc_buffer_stats(dest)->desired_plab_sz(G1CollectedHeap::heap()->workers()->active_workers()); + size_t gclab_word_size = alloc_buffer_stats(dest)->desired_plab_sz(); // Prevent humongous PLAB sizes for two reasons: // * PLABs are allocated using a similar paths as oops, but should // never be in a humongous region diff -r 12f312d694cd -r 23e6e981e89c hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp --- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Wed Apr 29 15:12:33 2015 +0300 +++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Thu May 07 10:32:42 2015 +0200 @@ -1033,7 +1033,7 @@ to()->set_concurrent_iteration_safe_limit(to()->top()); if (ResizePLAB) { - plab_stats()->adjust_desired_plab_sz(); + plab_stats()->adjust_desired_plab_sz(n_workers); } if (PrintGC && !PrintGCDetails) { @@ -1071,10 +1071,6 @@ _gc_tracer.report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions()); } -size_t ParNewGeneration::desired_plab_sz() { - return _plab_stats.desired_plab_sz(GenCollectedHeap::heap()->workers()->active_workers()); -} - static int sum; void ParNewGeneration::waste_some_time() { for (int i = 0; i < 100; i++) { diff -r 12f312d694cd -r 23e6e981e89c hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp --- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp Wed Apr 29 15:12:33 2015 +0300 +++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp Thu May 07 10:32:42 2015 +0200 @@ -411,7 +411,9 @@ return &_plab_stats; } - size_t desired_plab_sz(); + size_t desired_plab_sz() { + return _plab_stats.desired_plab_sz(); + } const ParNewTracer* gc_tracer() const { return &_gc_tracer; diff -r 12f312d694cd -r 23e6e981e89c hotspot/src/share/vm/gc_implementation/shared/plab.cpp --- a/hotspot/src/share/vm/gc_implementation/shared/plab.cpp Wed Apr 29 15:12:33 2015 +0300 +++ b/hotspot/src/share/vm/gc_implementation/shared/plab.cpp Thu May 07 10:32:42 2015 +0200 @@ -109,17 +109,10 @@ } } -// Calculates plab size for current number of gc worker threads. -size_t PLABStats::desired_plab_sz(uint no_of_gc_workers) { - assert(no_of_gc_workers > 0, "Number of GC workers should be larger than zero"); - - return align_object_size(_desired_net_plab_sz / MAX2(no_of_gc_workers, 1U)); -} - -// Compute desired plab size for one gc worker thread and latch result for later +// Compute desired plab size and latch result for later // use. This should be called once at the end of parallel // scavenge; it clears the sensor accumulators. -void PLABStats::adjust_desired_plab_sz() { +void PLABStats::adjust_desired_plab_sz(uint no_of_gc_workers) { assert(ResizePLAB, "Not set"); assert(is_object_aligned(max_size()) && min_size() <= max_size(), @@ -142,8 +135,7 @@ target_refills = 1; } size_t used = _allocated - _wasted - _unused; - // Assumed to have 1 gc worker thread - size_t recent_plab_sz = used / target_refills; + size_t recent_plab_sz = used / (target_refills * no_of_gc_workers); // Take historical weighted average _filter.sample(recent_plab_sz); // Clip from above and below, and align to object boundary @@ -154,7 +146,7 @@ if (PrintPLAB) { gclog_or_tty->print(" (plab_sz = " SIZE_FORMAT" desired_plab_sz = " SIZE_FORMAT") ", recent_plab_sz, new_plab_sz); } - _desired_net_plab_sz = new_plab_sz; + _desired_plab_sz = new_plab_sz; reset(); } diff -r 12f312d694cd -r 23e6e981e89c hotspot/src/share/vm/gc_implementation/shared/plab.hpp --- a/hotspot/src/share/vm/gc_implementation/shared/plab.hpp Wed Apr 29 15:12:33 2015 +0300 +++ b/hotspot/src/share/vm/gc_implementation/shared/plab.hpp Thu May 07 10:32:42 2015 +0200 @@ -150,13 +150,13 @@ // PLAB book-keeping. class PLABStats VALUE_OBJ_CLASS_SPEC { - size_t _allocated; // Total allocated - size_t _wasted; // of which wasted (internal fragmentation) - size_t _undo_wasted; // of which wasted on undo (is not used for calculation of PLAB size) - size_t _unused; // Unused in last buffer - size_t _desired_net_plab_sz; // Output of filter (below), suitably trimmed and quantized + size_t _allocated; // Total allocated + size_t _wasted; // of which wasted (internal fragmentation) + size_t _undo_wasted; // of which wasted on undo (is not used for calculation of PLAB size) + size_t _unused; // Unused in last buffer + size_t _desired_plab_sz;// Output of filter (below), suitably trimmed and quantized AdaptiveWeightedAverage - _filter; // Integrator with decay + _filter; // Integrator with decay void reset() { _allocated = 0; @@ -165,12 +165,12 @@ _unused = 0; } public: - PLABStats(size_t desired_net_plab_sz_, unsigned wt) : + PLABStats(size_t desired_plab_sz_, unsigned wt) : _allocated(0), _wasted(0), _undo_wasted(0), _unused(0), - _desired_net_plab_sz(desired_net_plab_sz_), + _desired_plab_sz(desired_plab_sz_), _filter(wt) { } @@ -182,12 +182,13 @@ return PLAB::max_size(); } - // Calculates plab size for current number of gc worker threads. - size_t desired_plab_sz(uint no_of_gc_workers); + size_t desired_plab_sz() { + return _desired_plab_sz; + } - // Updates the current desired PLAB size. Computes the new desired PLAB size with one gc worker thread, + // Updates the current desired PLAB size. Computes the new desired PLAB size, // updates _desired_plab_sz and clears sensor accumulators. - void adjust_desired_plab_sz(); + void adjust_desired_plab_sz(uint no_of_gc_workers); void add_allocated(size_t v) { Atomic::add_ptr(v, &_allocated);