Skip to content

Commit

Permalink
8312610: GenShen: Old generation available is unintentionally restric…
Browse files Browse the repository at this point in the history
…ted by mutator's available memory

Reviewed-by: kdnilsen, ysr
  • Loading branch information
William Kemper committed Jul 24, 2023
1 parent 97bbfb3 commit 6ca2eea
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
12 changes: 1 addition & 11 deletions src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,17 +885,7 @@ size_t ShenandoahGeneration::soft_available() const {

size_t ShenandoahGeneration::available(size_t capacity) const {
size_t in_use = used() + get_humongous_waste();
size_t available = in_use > capacity ? 0 : capacity - in_use;
// The collector reserve may eat into what the mutator is allowed to use. Make sure we are looking
// at what is available to the mutator when deciding whether to start a GC.
size_t usable = ShenandoahHeap::heap()->free_set()->available();
if (usable < available) {
log_debug(gc)("Usable (" SIZE_FORMAT "%s) is less than available (" SIZE_FORMAT "%s)",
byte_size_in_proper_unit(usable), proper_unit_for_byte_size(usable),
byte_size_in_proper_unit(available), proper_unit_for_byte_size(available));
available = usable;
}
return available;
return in_use > capacity ? 0 : capacity - in_use;
}

void ShenandoahGeneration::increase_capacity(size_t increment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ size_t ShenandoahGlobalGeneration::available() const {
return ShenandoahHeap::heap()->free_set()->available();
}

size_t ShenandoahGlobalGeneration::soft_available() const {
size_t available = this->available();

// Make sure the code below treats available without the soft tail.
assert(max_capacity() >= soft_max_capacity(), "Max capacity must be greater than soft max capacity.");
size_t soft_tail = max_capacity() - soft_max_capacity();
return (available > soft_tail) ? (available - soft_tail) : 0;
}

void ShenandoahGlobalGeneration::set_concurrent_mark_in_progress(bool in_progress) {
ShenandoahHeap* heap = ShenandoahHeap::heap();
if (in_progress && heap->mode()->is_generational()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ShenandoahGlobalGeneration : public ShenandoahGeneration {
virtual size_t used_regions() const override;
virtual size_t used_regions_size() const override;
virtual size_t available() const override;
virtual size_t soft_available() const override;

virtual void set_concurrent_mark_in_progress(bool in_progress) override;

Expand Down
12 changes: 12 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,15 @@ void ShenandoahYoungGeneration::add_collection_time(double time_seconds) {
ShenandoahGeneration::add_collection_time(time_seconds);
}
}

size_t ShenandoahYoungGeneration::available() const {
// The collector reserve may eat into what the mutator is allowed to use. Make sure we are looking
// at what is available to the mutator when reporting how much memory is available.
size_t available = this->ShenandoahGeneration::available();
return MIN2(available, ShenandoahHeap::heap()->free_set()->available());
}

size_t ShenandoahYoungGeneration::soft_available() const {
size_t available = this->ShenandoahGeneration::soft_available();
return MIN2(available, ShenandoahHeap::heap()->free_set()->available());
}
3 changes: 3 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class ShenandoahYoungGeneration : public ShenandoahGeneration {
}

virtual void add_collection_time(double time_seconds) override;

size_t available() const override;
size_t soft_available() const override;
};

#endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHYOUNGGENERATION_HPP

0 comments on commit 6ca2eea

Please sign in to comment.