Re: [PATCH] perf bench: Add -t/--threads option to perf bench mem mmap
From: Ankur Arora
Date: Tue Dec 16 2025 - 01:55:07 EST
Namhyung Kim <namhyung@xxxxxxxxxx> writes:
> Hi James,
>
> On Tue, Dec 09, 2025 at 01:01:25PM +0000, James Clark wrote:
>>
>>
>> On 07/12/2025 8:57 am, Namhyung Kim wrote:
>> > So that it can measure overhead of mmap_lock and/or per-VMA lock
>> > contention.
>> >
>> > $ perf bench mem mmap -f demand -l 1000 -t 1
>> > # Running 'mem/mmap' benchmark:
>> > # function 'demand' (Demand loaded mmap())
>> > # Copying 1MB bytes ...
>> >
>> > 2.914503 GB/sec
>> >
>> > $ perf bench mem mmap -f demand -l 1000 -t 2
>> > # Running 'mem/mmap' benchmark:
>> > # function 'demand' (Demand loaded mmap())
>> > # Copying 1MB bytes ...
>> >
>> > 888.769991 MB/sec
>> >
>> > $ perf bench mem mmap -f demand -l 1000 -t 3
>> > # Running 'mem/mmap' benchmark:
>> > # function 'demand' (Demand loaded mmap())
>> > # Copying 1MB bytes ...
>> >
>> > 757.658220 MB/sec
>> >
>> > $ perf bench mem mmap -f demand -l 1000 -t 4
>> > # Running 'mem/mmap' benchmark:
>> > # function 'demand' (Demand loaded mmap())
>> > # Copying 1MB bytes ...
>> >
>> > 316.410713 MB/sec
>>
>> Should this now say "MB/sec per thread" for nr_threads > 1? I think it could
>> be interpreted either way without a label, but I see you divided by
>> nr_threads in timeval2double().
>
> Right, thanks for the review. I think we can add it unconditionally.
Seconding the MB/sec per thread thing. But how about also adding some
kind of a variance indicator?
Maybe something like this:
$ perf bench mem mmap -f demand -l 1000 -t 4
# Running 'mem/mmap' benchmark:
# function 'demand' (Demand loaded mmap())
# Copying 1MB bytes ...
316.410713 MB/sec/thread ( +- 0.56% )
--
ankur