RFR (s): 8147003: Move BubbleUpRef test into CMS directory

Dmitry Fazunenko dmitry.fazunenko at oracle.com
Wed Feb 3 14:38:05 UTC 2016


Hi Bengt,

Thanks a lot for review and the comments provided.

On 03.02.2016 17:02, Bengt Rutisson wrote:
>
> Hi Dima,
>
> On 2016-02-03 14:24, Dmitry Fazunenko wrote:
>> Hi all,
>>
>> May I have a couple of reviews of a simple change:
>>
>> http://cr.openjdk.java.net/~dfazunen/8147003/webrev.00/
>> https://bugs.openjdk.java.net/browse/JDK-8147003
>>
>> Background:
>> This test is not new, I just took the source of existing closed test, 
>> performed some cosmetic changes and put in open.
>> The original logic has preserved unchanged.
>
> I'm fine with pushing this, but I would have preferred if the test 
> would just have been moved and the cosmetic changes would have been 
> done as a separate change. Not all of the cosmetic changes are obvious 
> improvements. I am for example not sure why you wanted to remove the 
> help text that was logged if the test was started with the wrong 
> arguments.

I moved the help text from the code into method description. It's very 
unlikely that code will be ever executed because the arguments are 
hardcoded.
So, it's better to have test argument description in the comments.

>
> As I said, unless anybody else thinks otherwise I am ok with this 
> change. But I would prefer if future changes like this was separated 
> in to a move that is as clean as possible and then a separate change 
> to clean the code up.

I was thinking about making the change in multiple steps, but decided 
that it would be over complicated for such a simple thing.
Okay, I got your point for the future.

I attached the diff between old and new version. It's hard to read, 
because of indent changes, so I didn't attach it earlier.

Thanks,
Dima


>
> Thanks,
> Bengt
>
>>
>> Thanks,
>> Dima
>

-------------- next part --------------
1a2,29
>  * Copyright (c) 2004, 2016, 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
>  * under the terms of the GNU General Public License version 2 only, as
>  * published by the Free Software Foundation.
>  *
>  * This code is distributed in the hope that it will be useful, but WITHOUT
>  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
>  * version 2 for more details (a copy is included in the LICENSE file that
>  * accompanied this code).
>  *
>  * You should have received a copy of the GNU General Public License version
>  * 2 along with this work; if not, write to the Free Software Foundation,
>  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
>  *
>  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
>  * or visit www.oracle.com if you need additional information or have any
>  * questions.
>  */
> 
> import java.lang.ref.ReferenceQueue;
> import java.lang.ref.WeakReference;
> import java.util.LinkedList;
> import java.util.ListIterator;
> 
> /*
6,10c34,39
<  * @summary CMS: vtest died with tiger b26
<  *          Fixed in JDK1.4.2_06 Respin b02
<  * @compile BubbleUpRef.java
<  * @run main/othervm -Xmx8m -XX:+UseConcMarkSweepGC -XX:-CMSYield -XX:-CMSPrecleanRefLists1 -XX:CMSInitiatingOccupancyFraction=0 BubbleUpRef 16000 50 10000
< */
---
>  * @summary Stress the behavior of ergonomics when the heap is nearly full and
>  *          stays nearly full.
>  * @run main/othervm
>  *  -XX:+UseConcMarkSweepGC -XX:-CMSYield -XX:-CMSPrecleanRefLists1
>  *  -XX:CMSInitiatingOccupancyFraction=0 -Xmx8m TestBubbleUpRef 16000 50 10000
>  */
12,34c41,64
< // Test program to stress the behavior of ergonomics when the
< // heap is nearly full and stays nearly full.
< //
< // This is a test to catch references that have been discovered
< // during concurrent marking and whose referents have been
< // cleared by the mutator.
< //
< // Allocate objects with weak references until the heap is full
< // Free the objects.
< // Do work so that concurrent marking has a chance to work
< // Clear the referents out of the weak references
< // System.gc() in the hopes that it will acquire the collection
< // Free the weak references
< // Do it again.
< //
< // Use the following VM options
< //      -Xmx8m -XX:-CMSYield [-XX:+UseConcMarkSweepGC] -XX:-CMSPrecleanRefLists1
< //      -XX:CMSInitiatingOccupancyFraction=0
< //
< // Use parameter
< //      <array size> = 16000
< //      <iterations> = 50
< //      <work> = 10000
---
> /**
>  * Test program to stress the behavior of ergonomics when the
>  * heap is nearly full and stays nearly full.
>  * This is a test to catch references that have been discovered
>  * during concurrent marking and whose referents have been
>  * cleared by the mutator.
>  * Allocate objects with weak references until the heap is full
>  * Free the objects.
>  * Do work so that concurrent marking has a chance to work
>  * Clear the referents out of the weak references
>  * System.gc() in the hopes that it will acquire the collection
>  * Free the weak references
>  * Do it again.
>  * 
>  * Use the following VM options
>  *     -Xmx8m -XX:-CMSYield [-XX:+UseConcMarkSweepGC] -XX:-CMSPrecleanRefLists1
>  *      -XX:CMSInitiatingOccupancyFraction=0
>  * 
>  * Use parameter:
>  *     args[0] - array size  (16000)
>  *     args[1] - iterations  (50)
>  *     args[2] - work        (10000)
>  */
> class MyList extends LinkedList {
36,39c66
< import java.text.*;
< import java.util.*;
< import java.lang.OutOfMemoryError;
< import java.lang.ref.*;
---
>     int[] a;
41,45c68,70
< class MyList extends LinkedList {
<   int[] a;
<   MyList(int size) {
<       a = new int[size];
<   }
---
>     MyList(int size) {
>         a = new int[size];
>     }
49,55c74,83
<   WeakReference ref;
<   MyRefList(Object o, ReferenceQueue rq) {
<     ref = new WeakReference(o, rq);
<   }
<   void clearReferent() {
<     ref.clear();
<   }
---
> 
>     WeakReference ref;
> 
>     MyRefList(Object o, ReferenceQueue rq) {
>         ref = new WeakReference(o, rq);
>     }
> 
>     void clearReferent() {
>         ref.clear();
>     }
58c86,87
< public class BubbleUpRef {
---
> public class TestBubbleUpRef {
> 
66c95,96
<     BubbleUpRef(int as, int cnt, int wk) {
---
> 
>     TestBubbleUpRef(int as, int cnt, int wk) {
72a103
> 
77,116c108,147
<              try {
<                  // Allocations
<                  MyList next = new MyList(arraySize);
<                  list.add(next);
<                  MyRefList nextRef = new MyRefList(next, rq);
<                  refList.add(nextRef);
<              } catch (OutOfMemoryError e) {
<                  // When the heap is full
<                  try {
<                      if (count++ > iterations) {
<                          return;
<                      }
<                      System.out.println("Freeing list");
<                      while (!list.isEmpty()) {
<                          list.removeFirst();
<                      }
<                      System.out.println("Doing work");
<                      int j = 0;
<                      for (int i = 1; i < workUnits; i++) {
<                        j = j + i;
<                      }
<                      System.out.println("Clearing refs");
<                      ListIterator listIt = refList.listIterator();
<                      while (listIt.hasNext()) {
<                          MyRefList next = (MyRefList) listIt.next();
<                          next.clearReferent();
<                      }
<                      System.gc();
<                      System.out.println("Freeing refs");
<                      while (!refList.isEmpty()) {
<                          refList.removeFirst();
<                      }
<                  } catch (OutOfMemoryError e2) {
<                      System.err.println("Out of Memory - 2 ");
<                      continue;
<                  }
<              } catch (Exception e) {
<                  System.err.println("Unexpected exception: " + e);
<                  return;
<              }
---
>             try {
>                 // Allocations
>                 MyList next = new MyList(arraySize);
>                 list.add(next);
>                 MyRefList nextRef = new MyRefList(next, rq);
>                 refList.add(nextRef);
>             } catch (OutOfMemoryError e) {
>                 // When the heap is full
>                 try {
>                     if (count++ > iterations) {
>                         return;
>                     }
>                     System.out.println("Freeing list");
>                     while (!list.isEmpty()) {
>                         list.removeFirst();
>                     }
>                     System.out.println("Doing work");
>                     int j = 0;
>                     for (int i = 1; i < workUnits; i++) {
>                         j = j + i;
>                     }
>                     System.out.println("Clearing refs");
>                     ListIterator listIt = refList.listIterator();
>                     while (listIt.hasNext()) {
>                         MyRefList next = (MyRefList) listIt.next();
>                         next.clearReferent();
>                     }
>                     System.gc();
>                     System.out.println("Freeing refs");
>                     while (!refList.isEmpty()) {
>                         refList.removeFirst();
>                     }
>                 } catch (OutOfMemoryError e2) {
>                     System.err.println("Out of Memory - 2 ");
>                     continue;
>                 }
>             } catch (Exception e) {
>                 System.err.println("Unexpected exception: " + e);
>                 return;
>             }
120,127c151,157
<     private static final String usage0
<         = "Usage: java BubbleUpRef ";
<     private static final String usage1
<         = "        <array size> is the size of the int array in a list item";
<     private static final String usage2
<         = "        <iterations> is the number of out-of-memory exceptions before exit";
<     private static final String usage3
<         = "        <workUnits> is the work done between allocations";
---
>     /**
>      * Test entry point.
>      *     args[0] - array size  (is the size of the int array in a list item)
>      *     args[1] - iterations  (is the number of out-of-memory exceptions before exit)
>      *     args[2] - work        (is the work done between allocations)
>      * @param args 
>      */
131,135c161
<             System.err.println(usage0);
<             System.err.println(usage1);
<             System.err.println(usage2);
<             System.err.println(usage3);
<             return;
---
>             throw new IllegalArgumentException("Wrong number of input argumets");
142,144c168,170
<         System.out.println("<array size> " + as + "\n" +
<                            "<OOM's> " + cnt + "\n" +
<                            "<work units> " + work + "\n");
---
>         System.out.println("<array size> " + as + "\n"
>                 + "<OOM's> " + cnt + "\n"
>                 + "<work units> " + work + "\n");
147,148c173
<         BubbleUpRef b;
<         b = new BubbleUpRef(as, cnt, work);
---
>         TestBubbleUpRef b = new TestBubbleUpRef(as, cnt, work);
160a186
> 


More information about the hotspot-gc-dev mailing list