RFR: 8252104: parallel heap inspection for ShenandoahHeap [v3]

Aleksey Shipilev shade at openjdk.java.net
Fri Sep 18 09:46:28 UTC 2020


On Fri, 18 Sep 2020 09:40:12 GMT, Lin Zang <lzang at openjdk.org> wrote:

>> src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp line 1470:
>> 
>>> 1468:     for (uint j = 0; j < roots_num; j++) {
>>> 1469:       uint stack_id = j % _num_workers;
>>> 1470:       oop obj = _roots_stack.pop();
>> 
>> I am not sure we can `pop()` the stack from multiple threads without any sort of synchronization. It might be better to
>> just walk the same roots from multiple threads, and then let the bitmap help us figure out if we have visited the root
>> already. See how `ShenandoahVerifierReachableTask` does it?
>
> Hi @shipilev,
> Thanks for your effort for reviewing this change!
> The method prepare_worker_queue() here is invoked in the constructor of ShenandoahParallelObjectIterator, which is
> designed to run in single thread.  The logic of using ParallelObjectIterator is as follows: (refer to code in
> hotspot/share/memory/heapInspection.cpp)
>  -  create instance of ParallelObjectIterator in shenandoahHeap:
>       ParallelObjectIterator* poi = Universe::heap()->parallel_object_iterator(gang->active_workers())
>  - create heap iteration task and run (invoke ParallelObjectIterator's method object_iterator())
>      ParHeapInspectTask task(**poi**, cit, filter);
>      // Run task with the active workers.
>      gang->run_task(&task);
> =======
> So the ShenandoahParallelObjectIterator iterate all roots in the single thread, collecting all roots in the
> roots_stack, then prepare the queues for every workers.  -- processed in constructor. And the workers start their
> processing from their queue, and then iterate all reachable objects. -- processed in work(uint worker_id)
> I have checked that ShenandoahVerifierReachableTask supports iterating roots parallelly, I didn't choose that way
> because I want to make every workers to start with nearly the same number of roots in their queue, hope it could help
> on inital work load balance.  Lin

Ah! I missed that part. I thought stack is used by the actual parallel workers. Nevermind my correctness comment then.

-------------

PR: https://git.openjdk.java.net/jdk/pull/67


More information about the serviceability-dev mailing list