8152438: Threads may do significant work out of the non-shared overflow buffer
authortschatzl
Wed, 22 Jun 2016 10:34:01 +0200
changeset 39407 2e75eb109278
parent 39405 314741ca98d5
child 39408 598092582b4e
8152438: Threads may do significant work out of the non-shared overflow buffer Summary: Before processing an element in the non-shared overflow buffer, try to push it into the local shared buffer to keep it full. Reviewed-by: jmasa, ehelin, sjohanss
hotspot/src/share/vm/gc/g1/g1ParScanThreadState.cpp
hotspot/src/share/vm/gc/shared/taskqueue.hpp
hotspot/src/share/vm/gc/shared/taskqueue.inline.hpp
--- a/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.cpp	Tue Jun 21 19:29:39 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.cpp	Wed Jun 22 10:34:01 2016 +0200
@@ -137,7 +137,9 @@
   do {
     // Drain the overflow stack first, so other threads can steal.
     while (_refs->pop_overflow(ref)) {
-      dispatch_reference(ref);
+      if (!_refs->try_push_to_taskqueue(ref)) {
+        dispatch_reference(ref);
+      }
     }
 
     while (_refs->pop_local(ref)) {
--- a/hotspot/src/share/vm/gc/shared/taskqueue.hpp	Tue Jun 21 19:29:39 2016 -0400
+++ b/hotspot/src/share/vm/gc/shared/taskqueue.hpp	Wed Jun 22 10:34:01 2016 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -330,6 +330,8 @@
 
   // Push task t onto the queue or onto the overflow stack.  Return true.
   inline bool push(E t);
+  // Try to push task t onto the queue only. Returns true if successful, false otherwise.
+  inline bool try_push_to_taskqueue(E t);
 
   // Attempt to pop from the overflow stack; return true if anything was popped.
   inline bool pop_overflow(E& t);
--- a/hotspot/src/share/vm/gc/shared/taskqueue.inline.hpp	Tue Jun 21 19:29:39 2016 -0400
+++ b/hotspot/src/share/vm/gc/shared/taskqueue.inline.hpp	Wed Jun 22 10:34:01 2016 +0200
@@ -103,6 +103,11 @@
   return true;
 }
 
+template <class E, MEMFLAGS F, unsigned int N>
+inline bool OverflowTaskQueue<E, F, N>::try_push_to_taskqueue(E t) {
+  return taskqueue_t::push(t);
+}
+
 // pop_local_slow() is done by the owning thread and is trying to
 // get the last task in the queue.  It will compete with pop_global()
 // that will be used by other threads.  The tag age is incremented