Interesting performance results on Crc port from zlib

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Jan 25 19:59:55 UTC 2021


On Mon, Jan 25, 2021 at 07:10:51PM +0000, Igor via Digitalmars-d wrote:
[...]
> I edited the example.c that comes with zlib to just do CRC calculation
> 100_000 times on 4K buffer and compiled it with its make file. But it
> first made a libz.a static lib and then it compiled example.c and
> linked them together. This resulted in executable that still
> calculates CRC in 262ms. But then I included crc32.c directly into
> example.c and compiled it as single compilation unit and now it does
> the job in 96ms. Same happened when I linked it with static lib using
> gcc -flto so LTO is used.
> 
> I had no idea this can have such big impact on performance. That's it,
> I am just using source libraries from now on :D

Inlining of functions in hot inner loops makes a big difference to
performance. This is especially important for CPU-intensive tasks like
computing CRCs.


--T


More information about the Digitalmars-d mailing list