Improve Archive Region Calculation (#211)#369
Conversation
|
@kcpeppe and I had some discussion about this. We want to verify whether archive regions are counted as old gen regions which may mean that these regions are being accounted for twice. |
Hi, just checked with the parse rules: And the way of how the tool kit processes the log: it seems it will differentitate the type of the region, and set the region summary accordingly |
|
@kkdlau - I found "OpenArchive" and "CloseArchive" as region types in jdk-11 and jdk-17. But I don't see an archive region type in jdk-8 or jdk-21. The only evidence I see of "Archive" appearing in a log trace is in the remembered set stats, but only in jdk-17. Do you have a log file with the pattern "Archive regions:"? |
|
@dsgrieve one of examples I found from
But it is quite surprising to know that the way JDK handles the archive region is changing over generations. I will also look at OpenJDK's G1CollectedHeap implementation to understand more about the issue. |
|
@dsgrieve I just walked through OpenJDK and found that Archive Regions are only available in JDK 14 and 17. JDK 14: https://github.com/openjdk/jdk/blob/ae39310243b0486f5a6f1049c6ec5f29db31170c/src/hotspot/share/gc/g1/g1HeapTransition.cpp#L174-L177 log_info(gc, heap)("Archive regions: " SIZE_FORMAT "->" SIZE_FORMAT,
_before._archive_length, after._archive_length);
log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K",
usage._archive_used / K, ((after._archive_length * HeapRegion::GrainBytes) - usage._archive_used) / K);JDK 8 doesn't have Archive Region type: typedef enum {
Unset,
Eden,
Survivor,
Old,
SingleHumongous,
StartsHumongous,
ContinuesHumongous
} RegionType;When I look at how the JVM collects region info, archive regions are not counted as old regions: if (r->is_old()) {
_usage._old_used += r->used();
_usage._old_region_count++;
} else if (r->is_archive()) {
_usage._archive_used += r->used();
_usage._archive_region_count++;I think, even though archive regions are only available in JDK 14 and 17, we can still subtract the size of archive regions from the total. Since the size of archive regions is 0 in other versions, and there is no double counting for old regions and archive regions. |
Previously, GCToolkit recognized archive regions but did not use this data in its calculations. This change improves the accuracy of tenured generation metrics for G1GCPause events.