Hello,
pagealign code (lib/pagealign_alloc.c) has a mistake whereas USE_MMAP code
uses the linked list to maintain the memory allocations. This is unnessary
as mmap() always returns memory aligned to the page size. Thus the buffer
could be passed as-is, similar to what HAVE_POSIX_MEMALIGN code is doing.
This suboptimal USE_MMAP code leads to serious performance regressions for
example with CVS 1.12.12 and later (earlier CVS versions did not use
pagealign and are thus unaffected). CVS also uses a list to maintain send
buffers. While pagealign code uses insert-to-head, the buffer list in CVS
are insert-to-tail. This combination leads to extremely expensive buffer
deallocation loops where CVS hogs 100% of the CPU for hours on end. We've
seen checkout of large repository to take over 2 hours.
Building CVS with USE_MMAP undefined (and thus using the posix_memalign
code) results in full checkout taking minutes vs hours.
The use of a list in the pagealign code is unnecessary to begin with. Even
the fallback malloc code could just arrange enough storage before the
returned pointer to store the actual pointer to pass to the free() call
there. This would make the routine O(1) rather than O(n) it is now. This,
of course, is less critical than fixing the USE_MMAP code.
I also posted about this discovery in Mastodon here:
https://infosec.exchange/@harrysintonen/115181692722241544
Regards,
--
l=2001;main(i){float o,O,_,I,D;for(;O=I=l/571.-1.75,l;)for(putchar(--l%80?
i:10),o=D=l%80*.05-2,i=31;_=O*O,O=2*o*O+I,o=o*o-_+D,o+_+_<4+D&i++<87;);puts
(" Harry 'Piru' Sintonen <[email protected]> https://www.iki.fi/sintonen");}