The Horror in the Standard Library
41–50 of 222 posts
Re: The Horror in the Standard Library
#42Things like this is why I was happy to see the LLVM project write their own C++ standard library. libstdc++ has always seemed a bit hacky and fragile to me. It's great to have an option which is a more modern, clean codebase. Have you tested to see if this works better with LLVM libc++?
Re: The Horror in the Standard Library
#43Yeah malloc() is pretty terrible in glibc by modern standards. For some workloads it just can't keep up and ends up fragmenting space in such a way that memory can't be returned to the OS (and thus be used for the page cache) and you end up in this performance spiral. I always deploy C++ server on jemalloc. Been doing it for years and while there's been occasional hicks up when updating it has provided much more pred…
This has nothing to do with glibc malloc()
Re: The Horror in the Standard Library
#44Things like this is why I was happy to see the LLVM project write their own C++ standard library. libstdc++ has always seemed a bit hacky and fragile to me. It's great to have an option which is a more modern, clean codebase. Have you tested to see if this works better with LLVM libc++?
Re: The Horror in the Standard Library
#45Actually it is C's malloc and free that is "broken". malloc() takes a size parameter, but free() doesn't. This imbalance means it can never be maximally efficient. Whatever GNU stdlibc++ is doing is probably, on balance, a net win for most programs. It's not exactly roses in C++ either of course. You can do better than the standard library facilities. Andrei Alexandrescu gave a great, entertaining, and technically el…
If free() took a size, what would that buy you? You are aware that malloc implementations tend to stick the size just before the part returned to the caller, right? eg. let's say you store size at p, return p+4 to caller, then have free() subtract 4 again to get at this "header"... So I'm guessing that's not your suggestion because free() wouldn't work at all without that kind of hack. Or more broadly, free() or real…
It's terrible for performance because you're giving up control, even if it is a little safer overall.
Re: The Horror in the Standard Library
#46I myself ran across this same scenario many years ago with a similar amount of hair pulling and eventually concluding that the GNU libstdc++ allocator wasn't reusing memory properly. Unfortunately, I was never able to pare down the application to the point that I had a reproducible test case to report upstream. GLIBCPP_FORCE_NEW was the solution for the near term and since I was deploying on Solaris boxes I eventuall…
It really bugs me that nobody links bug on bugtracker or filed it. I know I'm asking a lot and being an ass.
Re: The Horror in the Standard Library
#47Amazing write-up. Informative and gripping in its prose.
Re: The Horror in the Standard Library
#48This isn't particle physics, it's code: we don't have to guess, we can look at it and see how it works.
Re: The Horror in the Standard Library
#49Re: The Horror in the Standard Library
#50Exciting writing, but lacking a point.