News for hackers. Stuff that matters.
Re:How fast can you allocate a large block of memory in C++? by gumby on Thursday January 16, 2020 @01:25AM (#22062129)
Anonymous mmap() zeros memory so why is new wasting its cycles doing so too? I doubt any modern c++ standard library is using brk/sbrk I this day and age.
Re:How fast can you allocate a large block of memory in C++? by AstralStorm on Thursday January 16, 2020 @04:18AM (#22062869)
The thing is, tested C++ standard library implementation cannot assume a specific platform or implementation of libc. It's too portable.

Yes, you could add some platform and type specific speedups, it ends up a big mess.

In C++20 you get uninitialized allocation functions which do not have to initialize.

Re:How fast can you allocate a large block of memory in C++? by gumby on Thursday January 16, 2020 @11:58AM (#22066360)
By definition the libraries present a portable interface to underlying system resources and are full of platform specific code (I was a Cygnus founder so spent plenty of time deep in these issues at a time when there was more diversity). All posix is systems I know (e.g. Linux, BSD, Solaris, etc) return pages of zeros from anonymous mmap. I consider it a bug if they post process in this case.