]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/modules: use optimized crc32 from zlib
authorPatrick Palka <ppalka@redhat.com>
Tue, 13 Feb 2024 19:26:48 +0000 (14:26 -0500)
committerPatrick Palka <ppalka@redhat.com>
Tue, 13 Feb 2024 19:26:48 +0000 (14:26 -0500)
commit0eb9265fe737d901f484e4bcd73ffe386eb35693
tree3d03034cf4d3d884ec7bc8c6efd88ebd3f5764f7
parentcb76d7e47693364861e63ea3bb274b1b5295a943
c++/modules: use optimized crc32 from zlib

The current implementation of bytes::calc_crc computes the checksum one
byte at a time which turns out to be quite slow, accounting for 15% of
streaming in time for a modular Hello World.  We have a crc32_unsigned
version that processes 4 bytes at a time which we could use here, but
since we bundle zlib we might as well use its highly optimized crc
routines that can process up to 32 bytes at a time.

So this patch makes us use zlib's crc32 in this hot code path.  This
reduces stream in time for a modular Hello World by around 15% for me
with a release compiler.

gcc/cp/ChangeLog:

* Make-lang.in (CFLAGS-cp/module.o): Add $(ZLIBINC).
* module.cc: Include <zlib.h>.
(bytes::calc_crc): Use crc32 from zlib.
(bytes_out::set_crc): Use crc32_combine from zlib.

Reviewed-by: Jason Merill <jason@redhat.com>
gcc/cp/Make-lang.in
gcc/cp/module.cc