Skip to content

Commit 6123d57

Browse files
author
William Kemper
committedMar 18, 2025
8347620: Shenandoah: Use 'free' tag for free set related logging
Reviewed-by: kdnilsen Backport-of: 9782bfdd27da95c3bab9da6d46d695e717f465d8
1 parent 49bdb3a commit 6123d57

File tree

1 file changed

+71
-71
lines changed

1 file changed

+71
-71
lines changed
 

‎src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp

+71-71
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,8 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
10061006
in_new_region = r->is_empty();
10071007

10081008
if (in_new_region) {
1009-
log_debug(gc)("Using new region (" SIZE_FORMAT ") for %s (" PTR_FORMAT ").",
1010-
r->index(), ShenandoahAllocRequest::alloc_type_to_string(req.type()), p2i(&req));
1009+
log_debug(gc, free)("Using new region (" SIZE_FORMAT ") for %s (" PTR_FORMAT ").",
1010+
r->index(), ShenandoahAllocRequest::alloc_type_to_string(req.type()), p2i(&req));
10111011
assert(!r->is_affiliated(), "New region " SIZE_FORMAT " should be unaffiliated", r->index());
10121012
r->set_affiliation(req.affiliation());
10131013
if (r->is_old()) {
@@ -1027,8 +1027,8 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
10271027
assert(ctx->top_at_mark_start(r) == r->bottom(), "Newly established allocation region starts with TAMS equal to bottom");
10281028
assert(ctx->is_bitmap_range_within_region_clear(ctx->top_bitmap(r), r->end()), "Bitmap above top_bitmap() must be clear");
10291029
#endif
1030-
log_debug(gc)("Using new region (" SIZE_FORMAT ") for %s (" PTR_FORMAT ").",
1031-
r->index(), ShenandoahAllocRequest::alloc_type_to_string(req.type()), p2i(&req));
1030+
log_debug(gc, free)("Using new region (" SIZE_FORMAT ") for %s (" PTR_FORMAT ").",
1031+
r->index(), ShenandoahAllocRequest::alloc_type_to_string(req.type()), p2i(&req));
10321032
} else {
10331033
assert(r->is_affiliated(), "Region " SIZE_FORMAT " that is not new should be affiliated", r->index());
10341034
if (r->affiliation() != req.affiliation()) {
@@ -1460,23 +1460,23 @@ void ShenandoahFreeSet::find_regions_with_alloc_capacity(size_t &young_cset_regi
14601460
}
14611461
}
14621462
}
1463-
log_debug(gc)(" At end of prep_to_rebuild, mutator_leftmost: " SIZE_FORMAT
1464-
", mutator_rightmost: " SIZE_FORMAT
1465-
", mutator_leftmost_empty: " SIZE_FORMAT
1466-
", mutator_rightmost_empty: " SIZE_FORMAT
1467-
", mutator_regions: " SIZE_FORMAT
1468-
", mutator_used: " SIZE_FORMAT,
1469-
mutator_leftmost, mutator_rightmost, mutator_leftmost_empty, mutator_rightmost_empty,
1470-
mutator_regions, mutator_used);
1471-
1472-
log_debug(gc)(" old_collector_leftmost: " SIZE_FORMAT
1473-
", old_collector_rightmost: " SIZE_FORMAT
1474-
", old_collector_leftmost_empty: " SIZE_FORMAT
1475-
", old_collector_rightmost_empty: " SIZE_FORMAT
1476-
", old_collector_regions: " SIZE_FORMAT
1477-
", old_collector_used: " SIZE_FORMAT,
1478-
old_collector_leftmost, old_collector_rightmost, old_collector_leftmost_empty, old_collector_rightmost_empty,
1479-
old_collector_regions, old_collector_used);
1463+
log_debug(gc, free)(" At end of prep_to_rebuild, mutator_leftmost: " SIZE_FORMAT
1464+
", mutator_rightmost: " SIZE_FORMAT
1465+
", mutator_leftmost_empty: " SIZE_FORMAT
1466+
", mutator_rightmost_empty: " SIZE_FORMAT
1467+
", mutator_regions: " SIZE_FORMAT
1468+
", mutator_used: " SIZE_FORMAT,
1469+
mutator_leftmost, mutator_rightmost, mutator_leftmost_empty, mutator_rightmost_empty,
1470+
mutator_regions, mutator_used);
1471+
1472+
log_debug(gc, free)(" old_collector_leftmost: " SIZE_FORMAT
1473+
", old_collector_rightmost: " SIZE_FORMAT
1474+
", old_collector_leftmost_empty: " SIZE_FORMAT
1475+
", old_collector_rightmost_empty: " SIZE_FORMAT
1476+
", old_collector_regions: " SIZE_FORMAT
1477+
", old_collector_used: " SIZE_FORMAT,
1478+
old_collector_leftmost, old_collector_rightmost, old_collector_leftmost_empty, old_collector_rightmost_empty,
1479+
old_collector_regions, old_collector_used);
14801480

14811481
idx_t rightmost_idx = (mutator_leftmost == max_regions)? -1: (idx_t) mutator_rightmost;
14821482
idx_t rightmost_empty_idx = (mutator_leftmost_empty == max_regions)? -1: (idx_t) mutator_rightmost_empty;
@@ -1486,12 +1486,12 @@ void ShenandoahFreeSet::find_regions_with_alloc_capacity(size_t &young_cset_regi
14861486
rightmost_empty_idx = (old_collector_leftmost_empty == max_regions)? -1: (idx_t) old_collector_rightmost_empty;
14871487
_partitions.establish_old_collector_intervals(old_collector_leftmost, rightmost_idx, old_collector_leftmost_empty,
14881488
rightmost_empty_idx, old_collector_regions, old_collector_used);
1489-
log_debug(gc)(" After find_regions_with_alloc_capacity(), Mutator range [" SSIZE_FORMAT ", " SSIZE_FORMAT "],"
1490-
" Old Collector range [" SSIZE_FORMAT ", " SSIZE_FORMAT "]",
1491-
_partitions.leftmost(ShenandoahFreeSetPartitionId::Mutator),
1492-
_partitions.rightmost(ShenandoahFreeSetPartitionId::Mutator),
1493-
_partitions.leftmost(ShenandoahFreeSetPartitionId::OldCollector),
1494-
_partitions.rightmost(ShenandoahFreeSetPartitionId::OldCollector));
1489+
log_debug(gc, free)(" After find_regions_with_alloc_capacity(), Mutator range [%zd, %zd],"
1490+
" Old Collector range [%zd, %zd]",
1491+
_partitions.leftmost(ShenandoahFreeSetPartitionId::Mutator),
1492+
_partitions.rightmost(ShenandoahFreeSetPartitionId::Mutator),
1493+
_partitions.leftmost(ShenandoahFreeSetPartitionId::OldCollector),
1494+
_partitions.rightmost(ShenandoahFreeSetPartitionId::OldCollector));
14951495
}
14961496

14971497
// Returns number of regions transferred, adds transferred bytes to var argument bytes_transferred
@@ -1502,7 +1502,6 @@ size_t ShenandoahFreeSet::transfer_empty_regions_from_collector_set_to_mutator_s
15021502
const size_t region_size_bytes = ShenandoahHeapRegion::region_size_bytes();
15031503
size_t transferred_regions = 0;
15041504
ShenandoahLeftRightIterator iterator(&_partitions, which_collector, true);
1505-
idx_t rightmost = _partitions.rightmost_empty(which_collector);
15061505
for (idx_t idx = iterator.current(); transferred_regions < max_xfer_regions && iterator.has_next(); idx = iterator.next()) {
15071506
// Note: can_allocate_from() denotes that region is entirely empty
15081507
if (can_allocate_from(idx)) {
@@ -1748,13 +1747,13 @@ void ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old
17481747
// OLD regions that have available memory are already in the old_collector free set.
17491748
_partitions.move_from_partition_to_partition(idx, ShenandoahFreeSetPartitionId::Mutator,
17501749
ShenandoahFreeSetPartitionId::OldCollector, ac);
1751-
log_debug(gc)(" Shifting region " SIZE_FORMAT " from mutator_free to old_collector_free", idx);
1752-
log_debug(gc)(" Shifted Mutator range [" SSIZE_FORMAT ", " SSIZE_FORMAT "],"
1753-
" Old Collector range [" SSIZE_FORMAT ", " SSIZE_FORMAT "]",
1754-
_partitions.leftmost(ShenandoahFreeSetPartitionId::Mutator),
1755-
_partitions.rightmost(ShenandoahFreeSetPartitionId::Mutator),
1756-
_partitions.leftmost(ShenandoahFreeSetPartitionId::OldCollector),
1757-
_partitions.rightmost(ShenandoahFreeSetPartitionId::OldCollector));
1750+
log_trace(gc, free)(" Shifting region " SIZE_FORMAT " from mutator_free to old_collector_free", idx);
1751+
log_trace(gc, free)(" Shifted Mutator range [%zd, %zd],"
1752+
" Old Collector range [%zd, %zd]",
1753+
_partitions.leftmost(ShenandoahFreeSetPartitionId::Mutator),
1754+
_partitions.rightmost(ShenandoahFreeSetPartitionId::Mutator),
1755+
_partitions.leftmost(ShenandoahFreeSetPartitionId::OldCollector),
1756+
_partitions.rightmost(ShenandoahFreeSetPartitionId::OldCollector));
17581757
old_region_count++;
17591758
continue;
17601759
}
@@ -1771,13 +1770,13 @@ void ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old
17711770
// collection set, and they are easily evacuated because they have low density of live objects.
17721771
_partitions.move_from_partition_to_partition(idx, ShenandoahFreeSetPartitionId::Mutator,
17731772
ShenandoahFreeSetPartitionId::Collector, ac);
1774-
log_debug(gc)(" Shifting region " SIZE_FORMAT " from mutator_free to collector_free", idx);
1775-
log_debug(gc)(" Shifted Mutator range [" SSIZE_FORMAT ", " SSIZE_FORMAT "],"
1776-
" Collector range [" SSIZE_FORMAT ", " SSIZE_FORMAT "]",
1777-
_partitions.leftmost(ShenandoahFreeSetPartitionId::Mutator),
1778-
_partitions.rightmost(ShenandoahFreeSetPartitionId::Mutator),
1779-
_partitions.leftmost(ShenandoahFreeSetPartitionId::Collector),
1780-
_partitions.rightmost(ShenandoahFreeSetPartitionId::Collector));
1773+
log_trace(gc, free)(" Shifting region " SIZE_FORMAT " from mutator_free to collector_free", idx);
1774+
log_trace(gc, free)(" Shifted Mutator range [%zd, %zd],"
1775+
" Collector range [%zd, %zd]",
1776+
_partitions.leftmost(ShenandoahFreeSetPartitionId::Mutator),
1777+
_partitions.rightmost(ShenandoahFreeSetPartitionId::Mutator),
1778+
_partitions.leftmost(ShenandoahFreeSetPartitionId::Collector),
1779+
_partitions.rightmost(ShenandoahFreeSetPartitionId::Collector));
17811780
}
17821781
}
17831782

@@ -1789,8 +1788,8 @@ void ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old
17891788
}
17901789
size_t reserve = _partitions.available_in(ShenandoahFreeSetPartitionId::Collector);
17911790
if (reserve < to_reserve) {
1792-
log_debug(gc)("Wanted " PROPERFMT " for young reserve, but only reserved: " PROPERFMT,
1793-
PROPERFMTARGS(to_reserve), PROPERFMTARGS(reserve));
1791+
log_info(gc, free)("Wanted " PROPERFMT " for young reserve, but only reserved: " PROPERFMT,
1792+
PROPERFMTARGS(to_reserve), PROPERFMTARGS(reserve));
17941793
}
17951794
}
17961795
}
@@ -1841,34 +1840,41 @@ void ShenandoahFreeSet::log_status() {
18411840

18421841
#ifdef ASSERT
18431842
// Dump of the FreeSet details is only enabled if assertions are enabled
1844-
if (LogTarget(Debug, gc, free)::is_enabled()) {
1843+
LogTarget(Debug, gc, free) debug_free;
1844+
if (debug_free.is_enabled()) {
18451845
#define BUFFER_SIZE 80
1846+
LogStream ls(debug_free);
18461847

18471848
char buffer[BUFFER_SIZE];
18481849
for (uint i = 0; i < BUFFER_SIZE; i++) {
18491850
buffer[i] = '\0';
18501851
}
18511852

1852-
log_debug(gc)("FreeSet map legend:"
1853-
" M:mutator_free C:collector_free O:old_collector_free"
1854-
" H:humongous ~:retired old _:retired young");
1855-
log_debug(gc)(" mutator free range [" SIZE_FORMAT ".." SIZE_FORMAT "] allocating from %s, "
1856-
" collector free range [" SIZE_FORMAT ".." SIZE_FORMAT "], "
1857-
"old collector free range [" SIZE_FORMAT ".." SIZE_FORMAT "] allocates from %s",
1858-
_partitions.leftmost(ShenandoahFreeSetPartitionId::Mutator),
1859-
_partitions.rightmost(ShenandoahFreeSetPartitionId::Mutator),
1860-
_partitions.alloc_from_left_bias(ShenandoahFreeSetPartitionId::Mutator)? "left to right": "right to left",
1861-
_partitions.leftmost(ShenandoahFreeSetPartitionId::Collector),
1862-
_partitions.rightmost(ShenandoahFreeSetPartitionId::Collector),
1863-
_partitions.leftmost(ShenandoahFreeSetPartitionId::OldCollector),
1864-
_partitions.rightmost(ShenandoahFreeSetPartitionId::OldCollector),
1865-
_partitions.alloc_from_left_bias(ShenandoahFreeSetPartitionId::OldCollector)? "left to right": "right to left");
1853+
ls.cr();
1854+
ls.print_cr("Mutator free range [%zd..%zd] allocating from %s",
1855+
_partitions.leftmost(ShenandoahFreeSetPartitionId::Mutator),
1856+
_partitions.rightmost(ShenandoahFreeSetPartitionId::Mutator),
1857+
_partitions.alloc_from_left_bias(ShenandoahFreeSetPartitionId::Mutator)? "left to right": "right to left");
1858+
1859+
ls.print_cr("Collector free range [%zd..%zd] allocating from %s",
1860+
_partitions.leftmost(ShenandoahFreeSetPartitionId::Collector),
1861+
_partitions.rightmost(ShenandoahFreeSetPartitionId::Collector),
1862+
_partitions.alloc_from_left_bias(ShenandoahFreeSetPartitionId::Collector)? "left to right": "right to left");
1863+
1864+
ls.print_cr("Old collector free range [%zd..%zd] allocates from %s",
1865+
_partitions.leftmost(ShenandoahFreeSetPartitionId::OldCollector),
1866+
_partitions.rightmost(ShenandoahFreeSetPartitionId::OldCollector),
1867+
_partitions.alloc_from_left_bias(ShenandoahFreeSetPartitionId::OldCollector)? "left to right": "right to left");
1868+
ls.cr();
1869+
ls.print_cr("FreeSet map legend:");
1870+
ls.print_cr(" M/m:mutator, C/c:collector O/o:old_collector (Empty/Occupied)");
1871+
ls.print_cr(" H/h:humongous, X/x:no alloc capacity, ~/_:retired (Old/Young)");
18661872

18671873
for (uint i = 0; i < _heap->num_regions(); i++) {
18681874
ShenandoahHeapRegion *r = _heap->get_region(i);
18691875
uint idx = i % 64;
18701876
if ((i != 0) && (idx == 0)) {
1871-
log_debug(gc)(" %6u: %s", i-64, buffer);
1877+
ls.print_cr(" %6u: %s", i-64, buffer);
18721878
}
18731879
if (_partitions.in_free_set(ShenandoahFreeSetPartitionId::Mutator, i)) {
18741880
size_t capacity = alloc_capacity(r);
@@ -1882,17 +1888,11 @@ void ShenandoahFreeSet::log_status() {
18821888
size_t capacity = alloc_capacity(r);
18831889
buffer[idx] = (capacity == ShenandoahHeapRegion::region_size_bytes()) ? 'O' : 'o';
18841890
} else if (r->is_humongous()) {
1885-
if (r->is_old()) {
1886-
buffer[idx] = 'H';
1887-
} else {
1888-
buffer[idx] = 'h';
1889-
}
1891+
buffer[idx] = (r->is_old() ? 'H' : 'h');
1892+
} else if (alloc_capacity(r) == 0) {
1893+
buffer[idx] = (r->is_old() ? 'X' : 'x');
18901894
} else {
1891-
if (r->is_old()) {
1892-
buffer[idx] = '~';
1893-
} else {
1894-
buffer[idx] = '_';
1895-
}
1895+
buffer[idx] = (r->is_old() ? '~' : '_');
18961896
}
18971897
}
18981898
uint remnant = _heap->num_regions() % 64;
@@ -1901,7 +1901,7 @@ void ShenandoahFreeSet::log_status() {
19011901
} else {
19021902
remnant = 64;
19031903
}
1904-
log_debug(gc)(" %6u: %s", (uint) (_heap->num_regions() - remnant), buffer);
1904+
ls.print_cr(" %6u: %s", (uint) (_heap->num_regions() - remnant), buffer);
19051905
}
19061906
#endif
19071907

0 commit comments

Comments
 (0)
Please sign in to comment.