[PATCH] benchtests: Add memset zero fill benchmark tests
Noah Goldstein
goldstein.w.n@gmail.com
Tue Jul 13 18:47:12 GMT 2021
On Tue, Jul 13, 2021 at 12:15 PM Wilco Dijkstra via Libc-alpha <
libc-alpha@sourceware.org> wrote:
> Hi,
>
> > I like the idea of a benchmark specific for 0 on memset. However having
> two
> > implementations seems too much. I would rather see just one
> > bench-memset-zerofill.c. What I guess would be even better is to have
> this
> > performance test inside bench-memset.c and bench-memset-large.c.
>
> I agree just copying the files is not a good idea. Currently bench-memset
> and
> bench-memset-walk already test zero memsets. Bench-memset-large could just
> test zero since that is the most common, especially for large sizes.
> Reducing the
> number of non-zero tests in bench-memset would make it more representative
> -
> you could do the main set of tests with zero only and then have a small
> selection
> where it alternates between zero and non-zero.
>
I'm in favor of a seperate file. On some x86_64 systems writing zeros to a
cacheline
that has not been modified can leave the cacheline in an unmodified
state[1] which
affects memory bandwidth on the writeback to DRAM for larger regions. I can
imagine
we might want to test memset zero on unmodified vs modified region which
will require
unique setup that I think justifies a separate file (at least for
memset-large-zero).
[1] https://travisdowns.github.io/blog/2020/05/13/intel-zero-opt.html
>
> > Quoting Naohiro Tamura via Libc-alpha (2021-07-13 05:22:14)
> >> Memset takes 0 as the second parameter in most cases.
> >> More than 95% of memset takes 0 as the second parameter in case of
> >> Linux Kernel source code.
> > The Linux Kernel does not use glibc, it has his own memset
> implementation.
> >
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/string.c#n784
> > Therefore IMO this argument is not suited for this commit.
>
> The argument is true in general - you could simply state that almost all
> memset
> calls are zeroing without mentioning the Linux kernel. In some old stats
> from
> SPEC I saw about 1.8% non-zero memsets.
>
> Cheers,
> Wilco
More information about the Libc-alpha
mailing list