Skip to content

Commit

Permalink
Merge branch 'sapmachine' of https://github.com/SAP/SapMachine into m…
Browse files Browse the repository at this point in the history
…alloc_hook_replacement
  • Loading branch information
schmelter-sap committed Sep 2, 2023
2 parents 51cbd37 + 9d5e210 commit b281427
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
14 changes: 14 additions & 0 deletions src/hotspot/share/runtime/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,20 @@ const int ObjectAlignmentInBytes = 8;
\
product(uintx, VitalsSampleInterval, 10, \
"Vitals sample rate interval in seconds (default 10)") \
range(1, 24 * 3600) \
\
product(uintx, VitalsShortTermTableHours, 1, \
"The size of the short term vitals table in hours") \
range(1, 365 * 24) \
\
product(uintx, VitalsLongTermSampleIntervalMinutes, 60, \
"Vitals sample rate interval in minutes for the long term table " \
"(default 60)") \
range(1, 365 * 24 * 60) \
\
product(uintx, VitalsLongTermTableDays, 14, \
"The size of the long term vitals table in days") \
range(1, 10 * 365) \
\
product(bool, VitalsLockFreeSampling, false, DIAGNOSTIC, \
"When sampling vitals, omit any actions which require locking.") \
Expand Down
30 changes: 9 additions & 21 deletions src/hotspot/share/vitals/vitals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,22 +780,16 @@ class PrintSamplesClosure : public SampleTable::Closure {
// It takes care to feed new samples into these tables at the appropriate intervals.
class SampleTables: public CHeapObj<mtInternal> {

// Short term table: cover one hour, one sample per VitalsSampleInterval (default 10 seconds)
static const int short_term_span_seconds = 3600;

// Long term table: cover 14 days, one sample per hour
static const int long_term_span_seconds = short_term_span_seconds * 24 * 14;
static const int long_term_sample_interval = short_term_span_seconds;

static int short_term_tablesize() { return (short_term_span_seconds / VitalsSampleInterval) + 1; }
static const int long_term_tablesize = (long_term_span_seconds / long_term_sample_interval) + 1;
static int short_term_tablesize() { return (VitalsShortTermTableHours * 3600 / VitalsSampleInterval) + 1; }
static int long_term_tablesize() { return (VitalsLongTermTableDays * 24 * 60 / VitalsLongTermSampleIntervalMinutes) + 1; }

SampleTable _short_term_table;
SampleTable _long_term_table;
SampleTable _extremum_samples;
SampleTable _last_extremum_samples;

int _count;
int _large_table_count;

static void print_table(const SampleTable* table, outputStream* st,
const ColumnWidths* widths, const print_info_t* pi) {
Expand Down Expand Up @@ -835,10 +829,11 @@ class SampleTables: public CHeapObj<mtInternal> {

SampleTables()
: _short_term_table(short_term_tablesize()),
_long_term_table(long_term_tablesize),
_long_term_table(long_term_tablesize()),
_extremum_samples(Sample::num_values()),
_last_extremum_samples(Sample::num_values()),
_count(0)
_count(0),
_large_table_count(MAX2(1, (int) (VitalsLongTermSampleIntervalMinutes * 60 / VitalsSampleInterval)))
{}

void add_sample(const Sample* sample) {
Expand All @@ -850,7 +845,7 @@ class SampleTables: public CHeapObj<mtInternal> {
// only after an initial long term table interval has passed
_count++;
// Feed long term table
if ((_count % (long_term_sample_interval / VitalsSampleInterval)) == 0) {
if ((_count % _large_table_count) == 0) {
_long_term_table.add_sample(sample);
}

Expand Down Expand Up @@ -916,7 +911,7 @@ class SampleTables: public CHeapObj<mtInternal> {
_short_term_table.walk_table_locked(&mcwclos);

if (pi->csv == false) {
print_time_span(st, short_term_span_seconds);
print_time_span(st, VitalsShortTermTableHours * 3600);
}
print_headers(st, &widths, pi);
print_table(&_short_term_table, st, &widths, pi);
Expand All @@ -927,7 +922,7 @@ class SampleTables: public CHeapObj<mtInternal> {
ColumnWidths widths;
MeasureColumnWidthsClosure mcwclos(pi, &widths);
_long_term_table.walk_table_locked(&mcwclos);
print_time_span(st, long_term_span_seconds);
print_time_span(st, VitalsLongTermTableDays * 24 * 3600);
print_headers(st, &widths, pi);
print_table(&_long_term_table, st, &widths, pi);
st->cr();
Expand Down Expand Up @@ -1316,13 +1311,6 @@ bool initialize() {

log_info(vitals)("Vitals v%x", vitals_version);

// Adjust VitalsSampleInterval
if (VitalsSampleInterval == 0) {
log_warning(vitals)("Invalid VitalsSampleInterval (" UINTX_FORMAT ") specified. Vitals disabled.",
VitalsSampleInterval);
return false;
}

bool success = ColumnList::initialize();
success = success && Legend::initialize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public static void main(String[] args) throws Exception {
"-Xmx128m",
"-version"); // Note: explicitly omit Xlog:vitals, since the warning should always appear
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldContain("Invalid VitalsSampleInterval (0) specified. Vitals disabled.");
output.shouldHaveExitValue(1);
output.shouldContain("Improperly specified VM option 'VitalsSampleInterval=0'");

}

Expand Down

0 comments on commit b281427

Please sign in to comment.