From 61df0b5ab0b46d7405aaaf785d924f770e7544bc Mon Sep 17 00:00:00 2001 From: shshahma Date: Thu, 1 Sep 2016 06:16:05 -0700 Subject: [PATCH] 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 --- .../vm/gc_implementation/g1/g1ParScanThreadState.cpp | 6 ++++-- src/share/vm/utilities/taskqueue.hpp | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp b/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp index 406ac73d1..fc86a50cf 100644 --- a/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp +++ b/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -148,7 +148,9 @@ void G1ParScanThreadState::trim_queue() { 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)) { diff --git a/src/share/vm/utilities/taskqueue.hpp b/src/share/vm/utilities/taskqueue.hpp index fb9ea619b..8bdb38d31 100644 --- a/src/share/vm/utilities/taskqueue.hpp +++ b/src/share/vm/utilities/taskqueue.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, 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 @@ -453,6 +453,9 @@ public: // 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); @@ -486,6 +489,10 @@ bool OverflowTaskQueue::pop_overflow(E& t) return true; } +template +bool OverflowTaskQueue::try_push_to_taskqueue(E t) { + return taskqueue_t::push(t); +} class TaskQueueSetSuper { protected: static int randomParkAndMiller(int* seed0); -- GitLab