Consider Adding Thread Affinity
ron.pressler at oracle.com
Tue Dec 1 13:00:20 UTC 2020
In general, libraries, languages, and runtimes strive to have *as few* features as necessary, not as many as possible.
If you want to see a feature in the JDK, getting it seriously considered is simple: show that it is necessary. That
means showing some code that is sufficiently useful that runs sufficiently better with the feature than without.
E.g., we’re not going to add a feature that improves 1% of applications by 1%. So saying that something helps
somewhat sometimes isn’t enough.
On 1 December 2020 at 09:15:43, Suminda Sirinath Salpitikorala Dharmasena (sirinath1978m at gmail.com) wrote:
Thanks for the pointer.
I am aware of a few libraries tackling the Thread Affinity issue, but I was not aware of this specific solution. I will check it out.
I was hoping that this might eventually get tacked at the core library level than having to use a library.
Thanks again for the pointer.
On Tue, 1 Dec 2020 at 11:40, Enrico Olivelli <eolivelli at gmail.com> wrote:
In Apache Bookkeeper project we have this module, available on Maven Central
It allows to control thread affinity.
I hope that helps
Il Mar 1 Dic 2020, 00:15 David Holmes <david.holmes at oracle.com> ha scritto:
On 1/12/2020 2:53 am, Suminda Sirinath Salpitikorala Dharmasena wrote:
> This mainly aims to prevent cache misses as:
> - previously cached values of the thread may be in the cache
> - threads which share data can be targeted at a given core for better data
> - ensure threads are planned based on locks are common/shared
> resource usage which is known to the programmer than OS
> I believe this is an important feature to consider for performance.
Are you talking about virtual threads or regular (carrier) threads?
General thread affinity has been raised in the past but it is a highly
sensitive operation in relation to performance and extremely easy to
misuse (hurting not only the performance of your own application but
potentially the whole machine). Further to support thread affinity you
also need a way to expose detailed CPU topology information (sockets,
processors, cores) that does not presently exist in Java and which was
considered too machine/hardware specific to be considered a good
candidate for a portable Java API. With virtualized environments of
various forms, thread affinity is even harder to use.
Also note that the system/OS scheduler will itself try to address
low-level cache affinity when making scheduling decisions.
> On Mon, 30 Nov 2020 at 21:22, Ron Pressler <ron.pressler at oracle.com> wrote:
>> We have no concrete plans for doing so, but can you, perhaps, explain the
>> use-case and why it’s important?
>> — Ron
>> On 27 November 2020 at 14:17:07, Suminda Sirinath Salpitikorala Dharmasena
>> (sirinath1978m at gmail.com) wrote:
>> Is it possible to consider adding thread affinity to the Thread API?
More information about the loom-dev