Linux cpu affinity for forked benchmaks

Bernd Eckenfels ecki at zusammenkunft.net
Wed Jan 22 12:01:16 UTC 2020


Hello,

On Windows you use the start built-in

   cmd.exe /C start /affinity 255

It has however a 64 cpu limit so you might want to select also the processor group (with the help of picking a NUMA node)


--
http://bernd.eckenfels.net
________________________________
Von: jmh-dev <jmh-dev-bounces at openjdk.java.net> im Auftrag von Laurent Bourgès <bourges.laurent at gmail.com>
Gesendet: Tuesday, January 21, 2020 9:41:13 PM
An: Aleksey Shipilev <shade at redhat.com>
Cc: jmh-dev at openjdk.java.net <jmh-dev at openjdk.java.net>
Betreff: Re: Linux cpu affinity for forked benchmaks

Le mar. 21 janv. 2020 à 09:50, Aleksey Shipilev <shade at redhat.com> a écrit :

> On 1/21/20 9:45 AM, Laurent Bourgès wrote:
> > See
> >
> https://github.com/bourgesl/nearly-optimal-mergesort-code/blob/master/sort-bench/src/main/java/edu/sorting/bench/LinuxAffinityHelperProfiler.java
> >
> > Do you think that would be worth to integrate in JMH ?
>
> Maybe? But this is not the job for Profiler. Using it to inject "taskset"
> to the running process is
> the abuse of API. It should be somewhere in Runner. And the appropriate
> fallbacks should be present
> when taskset is not available, e.g. on Windows.
>

Thanks for your prompt feedback.
At least, it works and I advocate it is a quick & dirty hack ! So anybody
that have the same need (setting linux cpu affinity before benchmarks
(forks) knows that there is a dirty hack that does the job.

If there is any interest, I could rewrite the 'taskset' call in another
Runner API, I did not find any available hook.
As I practice not so much Windows, I do not have any idea how cpu affinity
could be set by the command line...

Laurent


More information about the jmh-dev mailing list