Glib is OK except for the fact that it has a memory cache on top of that of malloc. This prevents tools like asan or valgrind from detecting memory related bugs. It caused my team a lot of grief, to the point that we regretted the choice of using glib in the first place. I am not sure why there is a memory cache in the first place. Malloc may have been slow in the 90s, but these days there is no reason to cache and r…
> these days there is no reason to cache and reuse allocations. No, you are wrong. Ideas like that are a big reason that apps get slower despite hardware getting faster.
Libvirt: Adoption of GLib library to replace GNULIB and home grown code
21–30 of 66 posts
Re: Libvirt: Adoption of GLib library to replace GNULIB and home grown code
#22> These problems are common to many applications / libraries that are written in C and thus there are a number of libraries that attempt to provide a high level “standard library”. The GLib library is one such effort from the GNOME project developers that has long been appealing. I've been a fan of glib for some time, other than glib and apache libapr, what other "high level standard libraries" for C should I know ab…
I can't offer extra recommendations, but just wanted to offer full agreement. GLib is the awesome standard library I get to use everywhere thanks to gobject-introspection. From work projects in Vala, window manager¹, image viewer², video player³. It is especially useful with lua configurable projects, given the sparsity of the language itself. ¹ https://awesomewm.org/ ² https://github.com/muennich/sxiv - my user conf…
Re: Libvirt: Adoption of GLib library to replace GNULIB and home grown code
#23Glib is OK except for the fact that it has a memory cache on top of that of malloc. This prevents tools like asan or valgrind from detecting memory related bugs. It caused my team a lot of grief, to the point that we regretted the choice of using glib in the first place. I am not sure why there is a memory cache in the first place. Malloc may have been slow in the 90s, but these days there is no reason to cache and r…
> these days there is no reason to cache and reuse allocations. No, you are wrong. Ideas like that are a big reason that apps get slower despite hardware getting faster.
For example, I've done some work with audio or video. Nobody working on that goes straight to malloc on every packet or frame. It'd just be asking for pain.
But a general purpose allocator doing its own free-list on the assumption that libc is going to suck? I think that's outdated. If you do want to support it, I think it's better to allow the caller to replace the allocator through a function pointer, rather than just do it by default in a library.
Re: Libvirt: Adoption of GLib library to replace GNULIB and home grown code
#24Earlier quoted context omitted.
> these days there is no reason to cache and reuse allocations. No, you are wrong. Ideas like that are a big reason that apps get slower despite hardware getting faster.
Isn't the right way of doing this to use a different implementation of malloc, rather than wrapping malloc with your own meta-malloc?
Yup [0].
There's even other complete libraries like tcmalloc [1] and jemalloc [2].
[0] https://stackoverflow.com/a/262481/1111557
Re: Libvirt: Adoption of GLib library to replace GNULIB and home grown code
#25> These problems are common to many applications / libraries that are written in C and thus there are a number of libraries that attempt to provide a high level “standard library”. The GLib library is one such effort from the GNOME project developers that has long been appealing. I've been a fan of glib for some time, other than glib and apache libapr, what other "high level standard libraries" for C should I know ab…
If your C umbrella includes C++, Qt has a number of (non-GUI) high-level libraries that can be useful for applications.
Re: Libvirt: Adoption of GLib library to replace GNULIB and home grown code
#26Earlier quoted context omitted.
> these days there is no reason to cache and reuse allocations. No, you are wrong. Ideas like that are a big reason that apps get slower despite hardware getting faster.
I think it becomes an application specific or domain specific thing. For example, I've done some work with audio or video. Nobody working on that goes straight to malloc on every packet or frame. It'd just be asking for pain. But a general purpose allocator doing its own free-list on the assumption that libc is going to suck? I think that's outdated. If you do want to support it, I think it's better to allow the call…
Re: Libvirt: Adoption of GLib library to replace GNULIB and home grown code
#27Earlier quoted context omitted.
I think it becomes an application specific or domain specific thing. For example, I've done some work with audio or video. Nobody working on that goes straight to malloc on every packet or frame. It'd just be asking for pain. But a general purpose allocator doing its own free-list on the assumption that libc is going to suck? I think that's outdated. If you do want to support it, I think it's better to allow the call…
glib does not always use one, the default is normal malloc and it provides another allocator api as an option.
I think libstc++ on the other hand does or did have such a cache as an always-on thing though. So not unheard of.
Re: Libvirt: Adoption of GLib library to replace GNULIB and home grown code
#28Earlier quoted context omitted.
Isn't the right way of doing this to use a different implementation of malloc, rather than wrapping malloc with your own meta-malloc?
> Isn't the right way of doing this to use a different implementation of malloc, rather than wrapping malloc with your own meta-malloc? Yup [0]. There's even other complete libraries like tcmalloc [1] and jemalloc [2]. [0] https://stackoverflow.com/a/262481/1111557 [1] https://github.com/google/tcmalloc [2] https://github.com/jemalloc/jemalloc
Re: Libvirt: Adoption of GLib library to replace GNULIB and home grown code
#29Glib is OK except for the fact that it has a memory cache on top of that of malloc. This prevents tools like asan or valgrind from detecting memory related bugs. It caused my team a lot of grief, to the point that we regretted the choice of using glib in the first place. I am not sure why there is a memory cache in the first place. Malloc may have been slow in the 90s, but these days there is no reason to cache and r…
Re: Libvirt: Adoption of GLib library to replace GNULIB and home grown code
#30Earlier quoted context omitted.
If your C umbrella includes C++, Qt has a number of (non-GUI) high-level libraries that can be useful for applications.
Qt is more like gtk rather than glib. Although it does come with a fantastic core library. But if you can move to C++, the standard library already offers great replacements for most glib features. Glib exists mostly because the C standard library is lacking in many aspects.