Date: Fri, 8 Sep 2017 20:09:14 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323329 - head/sys/sys Message-ID: <201709082009.v88K9EGW006964@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Fri Sep 8 20:09:14 2017 New Revision: 323329 URL: https://svnweb.freebsd.org/changeset/base/323329 Log: Allow __builtin_memset instead of bzero for small buffers of known size In particular this eliminates function calls and related register save/restore when only few writes would suffice. Example speed up can be seen in a fstat microbenchmark on AMD Ryzen cpus, where the throughput went up by ~4.5%. Thanks to cem@ for benchmarking and reviewing the patch. MFC after: 1 week Modified: head/sys/sys/systm.h Modified: head/sys/sys/systm.h ============================================================================== --- head/sys/sys/systm.h Fri Sep 8 20:07:53 2017 (r323328) +++ head/sys/sys/systm.h Fri Sep 8 20:09:14 2017 (r323329) @@ -258,6 +258,12 @@ void hexdump(const void *ptr, int length, const char * #define ovbcopy(f, t, l) bcopy((f), (t), (l)) void bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len); void bzero(void * _Nonnull buf, size_t len); +#define bzero(buf, len) ({ \ + if (__builtin_constant_p(len) && (len) <= 64) \ + __builtin_memset((buf), 0, (len)); \ + else \ + bzero((buf), (len)); \ +}) void explicit_bzero(void * _Nonnull, size_t); void *memcpy(void * _Nonnull to, const void * _Nonnull from, size_t len);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709082009.v88K9EGW006964>