[3A2000-B/4way] ParallelOldGC: add SYNC in BlockData

Tue, 03 May 2016 13:57:12 -0400

author
Jin
date
Tue, 03 May 2016 13:57:12 -0400
changeset 34
76df293e57aa
parent 33
52672a450193
child 35
a2cbf57bd9f3

[3A2000-B/4way] ParallelOldGC: add SYNC in BlockData

When running on 3A2000B-4way, compiler crashes in Full GC.

In BlockData, multiple threads writes to the same
memory location without explict synchronization,

Sync is required for access correctness.

Ref: http://10.2.5.21:8000/projects/java/wiki/Jgj-log-2016-5-4_

[List.java]

public class List extends Thread {
public List sub[];
public List next;

public List() {
this.next = null;
}

public void insert(int n) {
List p = new List();
p.next = this.next;
this.next = p;

p.sub = new List[404];
for (int i = 0; i < 404; i++)
p.sub[i] = new List();
}

public void run()
{
int i = 0;
while(true)
insert(i++);
}

public static void main(String[] args) throws Exception {
int N = 16;
Thread[] threads = new Thread[N];

for (int i = 0; i < N; i++)
{
List th = new List();
threads[i] = th;
th.start();
}
System.err.println(N + " threads Created.");

for (int i = 0; i < N; i++)
{
threads[i].join();
}
System.err.println("Done.");
}
}

[1.sh]

i=1

while true; do

echo === $i ===
date

#/opt/j2sdk-image-test/bin/java \
time \
numactl --cpunodebind=0 --membind=0 \
/mnt/j2sdk-image/bin/java \
-Xmx62M -Xms62M \
-XX:+PrintGC \
-XX:-UseCompressedOops \
-XX:+UnlockDiagnosticVMOptions \
-XX:ParallelGCThreads=2 \
-XX:+ScavengeBeforeFullGC \
-XX:+VerifyAfterGC \
List &
#-XX:+UseNUMA \

sleep 10

killall -9 java

i=$(($i+1))
done

Effect:
* Before: crashed in VerifyAfterGC
* After: 50 times OK
* compiler(-bt 16): OK, 97.86 ops/m%

src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Fri Apr 29 12:46:05 2016 -0400
     1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Tue May 03 13:57:12 2016 -0400
     1.3 @@ -3233,6 +3233,13 @@
     1.4      if (new_block != cur_block) {
     1.5        cur_block = new_block;
     1.6        sd.block(cur_block)->set_offset(bitmap->bits_to_words(live_bits));
     1.7 +
     1.8 +#ifdef MIPS64
     1.9 +      /* 2016/5/4 Jin: On 3A2000-B, when multiple threads write to
    1.10 +         the same memory location without explict synchronization,
    1.11 +         sync is required for access correctness. */
    1.12 +      OrderAccess::fence();
    1.13 +#endif
    1.14      }
    1.15  
    1.16      const size_t end_bit = bitmap->find_obj_end(beg_bit, range_end);

mercurial