Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8228658: test GetTotalSafepointTime.java fails on fast Linux machines with Total safepoint time 0 ms #578

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -39,47 +39,33 @@ public class GetTotalSafepointTime {
private static HotspotRuntimeMBean mbean =
(HotspotRuntimeMBean)ManagementFactoryHelper.getHotspotRuntimeMBean();

private static final long NUM_THREAD_DUMPS = 100;

// Careful with these values.
private static final long MIN_VALUE_FOR_PASS = 1;
private static final long MAX_VALUE_FOR_PASS = Long.MAX_VALUE;

private static boolean trace = false;
// Thread.getAllStackTraces() should cause safepoints.
// If this test is failing because it doesn't,
// MIN_VALUE_FOR_PASS should be reset to 0
public static long executeThreadDumps(long initial_value) {
long value;
do {
Thread.getAllStackTraces();
value = mbean.getTotalSafepointTime();
} while (value == initial_value);
return value;
}

public static void main(String args[]) throws Exception {
if (args.length > 0 && args[0].equals("trace")) {
trace = true;
}

// Thread.getAllStackTraces() should cause safepoints.
// If this test is failing because it doesn't,
// MIN_VALUE_FOR_PASS should be reset to 0
for (int i = 0; i < NUM_THREAD_DUMPS; i++) {
Thread.getAllStackTraces();
}

long value = mbean.getTotalSafepointTime();
long value = executeThreadDumps(0);
System.out.println("Total safepoint time (ms): " + value);

if (trace) {
System.out.println("Total safepoint time (ms): " + value);
}

if (value < MIN_VALUE_FOR_PASS || value > MAX_VALUE_FOR_PASS) {
if (value < MIN_VALUE_FOR_PASS) {
throw new RuntimeException("Total safepoint time " +
"illegal value: " + value + " ms " +
"(MIN = " + MIN_VALUE_FOR_PASS + "; " +
"MAX = " + MAX_VALUE_FOR_PASS + ")");
"(MIN = " + MIN_VALUE_FOR_PASS + ")");
}

for (int i = 0; i < 2 * NUM_THREAD_DUMPS; i++) {
Thread.getAllStackTraces();
}
long value2 = mbean.getTotalSafepointTime();

if (trace) {
System.out.println("Total safepoint time2 (ms): " + value2);
}
long value2 = executeThreadDumps(value);
System.out.println("Total safepoint time (ms): " + value2);

if (value2 <= value) {
throw new RuntimeException("Total safepoint time " +
Expand Down