RFR(M): 7033917: closed/compiler/6507107/HeapwalkingTest.java sometimes works too long

Vladimir Kozlov vladimir.kozlov at oracle.com
Fri May 30 18:06:45 UTC 2014

The idead is good but the implementation is way too complex. What you 
want is to exit loops. You don't need special iterators for that.

public class RuntimeEstimator {
     private long end;
     private long last;
     private long worst_iteration;

     public Estimator(long duration) { // duration in seconds
         last = System.currentTimeMillis();
         end = last + duration*1000;
         worst_iteration = 0;

     public boolean timeout() {
         long now = System.currentTimeMillis();
         long iteration = now - last;
         last = now;
         if (iteration >  worst_iteration) {
             worst_iteration = iteration;
         // *2 to be conservative
         return (now + worst_iteration_time*2) > end;

In a test's loop you will just check if(est.timeout()) and exit loop.


On 5/23/14 7:30 AM, Morris Meyer wrote:
> Folks,
> During the nightly testing we have a class of bugs that crop up with
> compiler flags that change the performance dynamic of the test, such as
> -Xcomp and -XX:+DeoptimizeALot.
> Instead of tweaking the test parameters, I have created an Estimator
> class that takes a work List - and creates an Iterator that is looking
> at the expiration clock for the test.  Instead of the test failing out
> for taking too much time for an arbitrary number of iterations, the
> iterator ends, and Estimator will produce a timeout factor suitable for
> the -Dtest.timeout.factor flag.
> I've added an EstimatorTest to testlibrary_tests that tests the
> Estimator with three scenarios, too much time, not enough time and just
> enough time.
> This test has also been through JPRT.   The changes HeapwalkingTest will
> be sent out for review to the closed list.
> Thanks much,
>          --morris meyer
> WEBREV - http://cr.openjdk.java.net/~morris/JDK-7033917-hotspot.01
> JBS - https://bugs.openjdk.java.net/browse/JDK-7033917

More information about the hotspot-compiler-dev mailing list