posix_memalign performance regression in 2.38?
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Fri Aug 4 14:12:44 GMT 2023
On 03/08/23 23:52, Xi Ruoyao via Libc-alpha wrote:
> Hi,
>
> There seems a performance regression of posix_memalign in Glibc-2.38:
>
> $ cat t.c
> #include <stdlib.h>
> int main()
> {
> void *buf;
> for (int i = 0; i < (1 << 16); i++)
> posix_memalign(&buf, 64, 16);
> }
> $ cc t.c
> $ time ./a.out
>
> real 0m0.008s
> user 0m0.005s
> sys 0m0.003s
> $ time ~/sources/lfs/glibc-2.38/build/testrun.sh ./a.out
>
> real 0m4.376s
> user 0m4.369s
> sys 0m0.007s
>
> The behavior seems worse than quadratic: if I change "1 << 16" to "1 <<
> 17", I get:
>
> $ time ~/sources/lfs/glibc-2.38/build/testrun.sh ./a.out
>
> real 0m28.597s
> user 0m28.568s
> sys 0m0.022s
>
> I've not bisected for this yet.
>
It seems to be caused by 24cdd6c71debfd10a9f7cb217fe2a2c4c486ed6f, where
posix_memalign now calls chunk_ok_for_memalign (which takes most of time).
DJ, any idea on how we can improve this?
More information about the Libc-alpha
mailing list