Live data from Hacker News

Comparison of C/POSIX standard library implementations for Linux

etalabs.net

41–50 of 58 posts

Re: Comparison of C/POSIX standard library implementations for Linux

#41

Please note that the linked comparison table has been unmaintained for a while. This is even explicitly stated on the legacy musl libc website[0][0] ( i.e. , “The (mostly unmaintained) libc comparison is still available on etalabs.net.”). [0]: https://www.musl-libc.org

This comparison was last updated around 2016-2017. Since then, glibc has improved its size efficiency (particularly with link-time optimization), musl has enhanced its POSIX compliance, and several performance optimizations have landed in both projects.

Re: Comparison of C/POSIX standard library implementations for Linux

#42

Fun libc comparison by the author of musl. My getaway is: glibc is bloated but fast. Quite unexpected combination. Am I right?

Microbenchmarks tend to favour extreme unrolling and other "speed at any cost" tricks that often show up as negatives in macrobenchmarks.

Re: Comparison of C/POSIX standard library implementations for Linux

#43

Earlier quoted context omitted.

The Fil-C stack is composed of : - Userland: the place where you C code lives. Like the normal userland you're familiar with, but everything is compiled with Fil-C, so it's memory safe. - Yololand: the place where Fil-C's runtime lives. Fil-C's runtime is about 100,000 lines of C code (almost entirely written by me), which currently has libc as a dependency (because the runtime makes syscalls using the normal C funct…

Why does yoyoland need to use libc’s memcpy? Can’t you just use __builtin_memcpy? On Linux, if all you need is syscalls, you can just write your own syscall wrapper-like Go does. Doesn’t work on some other operating systems (e.g. Solaris/Illumos, OpenBSD, macOS, Windows) where the system call interface is private to the system shared libraries

You keep repeating the name wrong: yololand, not yololand.

Re: Comparison of C/POSIX standard library implementations for Linux

#45

Fun libc comparison by the author of musl. My getaway is: glibc is bloated but fast. Quite unexpected combination. Am I right?

It’s not shocking. More complex implementations using more sophisticated algorithms can be faster. That’s not always true, but it often is. For example, look at some of the string search algorithms used by things like ripgrep. They’re way more complex than just looping across the input and matching character by character, and they pay off. Something like glibc has had decades to swap in complex, fast code for simple-…

Yeah look at even strlen()

https://github.com/lattera/glibc/blob/master/string/strlen.c

Re: Comparison of C/POSIX standard library implementations for Linux

#46

My own perf comparison: when I switched from Fil-C running on my system’s libc (recent glibc) for yololand to my own build of musl, I got a 1-2% perf regression. My best guess is that it’s because glibc’s memcpy/memmove/memset are better. Couldn’t have been the allocator since Fil-C’s runtime has its own allocator.

Are you sure they were being used at all?

GCC replaces memcpy/memmove/memset with its own intrisics, if compiling in high optimization levels.

Re: Comparison of C/POSIX standard library implementations for Linux

#47
post #46

My own perf comparison: when I switched from Fil-C running on my system’s libc (recent glibc) for yololand to my own build of musl, I got a 1-2% perf regression. My best guess is that it’s because glibc’s memcpy/memmove/memset are better. Couldn’t have been the allocator since Fil-C’s runtime has its own allocator.

Are you sure they were being used at all? GCC replaces memcpy/memmove/memset with its own intrisics, if compiling in high optimization levels.

Yes they were being used.

Re: Comparison of C/POSIX standard library implementations for Linux

#48

Earlier quoted context omitted.

Why does yoyoland need to use libc’s memcpy? Can’t you just use __builtin_memcpy? On Linux, if all you need is syscalls, you can just write your own syscall wrapper-like Go does. Doesn’t work on some other operating systems (e.g. Solaris/Illumos, OpenBSD, macOS, Windows) where the system call interface is private to the system shared libraries

You keep repeating the name wrong: yololand, not yololand.

GP was saying 'yoyoland', when it's 'yololand' (as in YOLO?).

Re: Comparison of C/POSIX standard library implementations for Linux

#49

Earlier quoted context omitted.

You keep repeating the name wrong: yololand, not yololand.

GP was saying 'yoyoland', when it's 'yololand' (as in YOLO?).

Yeah YOLO.

I needed a fun term to refer to the C that isn’t Fil-C. I call it Yolo-C.

Hence yololand - the part of the Fil-C process that contains a bit of Yolo-C code for the Fil-C runtime.

Re: Comparison of C/POSIX standard library implementations for Linux

#50

Earlier quoted context omitted.

GP was saying 'yoyoland', when it's 'yololand' (as in YOLO?).

Yeah YOLO. I needed a fun term to refer to the C that isn’t Fil-C. I call it Yolo-C. Hence yololand - the part of the Fil-C process that contains a bit of Yolo-C code for the Fil-C runtime.

Thanks. I went looking and saw this in the Fil-C manifesto:

> It's even possible to allocate memory using malloc from within a signal handler (which is necessary because Fil-C heap-allocates stack allocations).

Hmm, really? All stack allocations are heap-allocated? Doesn't that make Fil-C super slow? Is there no way to do stack allocation? Or did I misread what you meant by 'stack allocations'?

Post reply on HN