RFR: 8193559: ugly DO_JAVA_THREADS macro should be replaced [v4]
eosterlund at openjdk.java.net
Sat Jul 31 08:14:31 UTC 2021
On Fri, 30 Jul 2021 16:26:35 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:
>> src/hotspot/share/runtime/threadSMR.inline.hpp line 59:
>>> 57: assert_not_singular();
>>> 58: assert_dereferenceable();
>>> 59: Prefetch::read(const_cast<JavaThread**>(_thread_ptr), PrefetchScanIntervalInBytes);
>> This prefetch is included because the old code had it. But I'm dubious about it. This is just linear iteration through an array, which seems like the canonical best case for leaving it to the hardware, rather than doing cachelinesize/ptrsize software prefetches per cache line. I'm hoping the original authors can comment.
> The original author that added the prefetch is @fisk. He's reviewed an earlier
> version of this fix and I'm hoping he's around to review this version.
I agree that it should be okay without prefetch. I added it when I was running on a 4096 strand SPARC machine running over 8000 threads, and walking the list would approach 1 ms. While intuitively linear scan should be good enough, I did actually measure slight improvements with explicit prefetching, and the slight improvements did seem worth it at the time as the amount of time spent in there was non-trivial.
Now we don't support that kind of hardware any longer, so I don't think this trick would necessarily spark as much joy any longer.
I don't mind if we do or do not perform the prefetching. I'm okay either way.
More information about the hotspot-gc-dev