Hello, I'm curious what's need to be done in order to have by-four version of CRC32 enabled by default let's say at least on amd64? Attached patch is quite aggressive as I put an option into generic GENERIC, but still I hope it may be usable as a starting point. Performance of CRC32 went up from 360 MB/s to 970 MB/s on my e3-1220v3 with this compiled in. Thanks! Karel
diff --git a/sys/conf/GENERIC b/sys/conf/GENERIC index 4aefba1..7ab41d1 100644 --- a/sys/conf/GENERIC +++ b/sys/conf/GENERIC @@ -43,6 +43,7 @@ option MSDOSFS # MS-DOS file system option FIFO # FIFOs; RECOMMENDED option TMPFS # efficient memory file system option FUSE # FUSE +option BYFOUR # faster CRC32 implementation option SOCKET_SPLICE # Socket Splicing for TCP and UDP option TCP_SACK # Selective Acknowledgements for TCP diff --git a/sys/lib/libz/Makefile b/sys/lib/libz/Makefile index 93f04fe..81dc850 100644 --- a/sys/lib/libz/Makefile +++ b/sys/lib/libz/Makefile @@ -5,8 +5,6 @@ LIB= z NOPIC= NOPROFILE= -# Tweak knobs to generate small libz code -CPPFLAGS+= -DSLOW -DSMALL -DNOBYFOUR -DNO_GZIP -DDYNAMIC_CRC_TABLE CPPFLAGS+= -I. ${ZCPPFLAGS} # files to be copied down from libz. diff --git a/sys/lib/libz/crc32.c b/sys/lib/libz/crc32.c index eac7d74..67f7775 100644 --- a/sys/lib/libz/crc32.c +++ b/sys/lib/libz/crc32.c @@ -29,12 +29,15 @@ #define local static -#ifndef _KERNEL /* Find a four-byte integer type for crc32_little() and crc32_big(). */ #ifndef NOBYFOUR # ifdef STDC /* need ANSI C limits.h to determine sizes */ +#ifndef _KERNEL # include <limits.h> # define BYFOUR +#else +# include <sys/limits.h> +#endif # if (UINT_MAX == 0xffffffffUL) typedef unsigned int u4; # else @@ -50,10 +53,12 @@ # endif # endif /* STDC */ #endif /* !NOBYFOUR */ -#endif /* Definitions for doing the crc four data bytes at a time. */ #ifdef BYFOUR +#ifdef _KERNEL +#include <sys/stdint.h> +#endif # define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \ (((w)&0xff00)<<8)+(((w)&0xff)<<24)) local unsigned long crc32_little OF((unsigned long,