Linux cpu affinity for forked benchmaks
Ralf H
ralf at pkmd.de
Wed Jan 22 01:08:36 UTC 2020
Am 21. Januar 2020 21:41:13 MEZ schrieb "Laurent Bourgès" <bourges.laurent at gmail.com>:
>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
Actually, there are affinity packages, like the one by openHFT. I did a windows port a while ago and added cpu layout discovery. Allows to bind the current thread to one or more logical cpus.
--
More information about the jmh-dev
mailing list