GNOME Bugzilla – Bug 732284
bufferlist: optimisation: pre-allocate buffer array in one go with the buffer list
Last modified: 2014-07-24 10:07:48 UTC
Created attachment 279313 [details] [review] bufferlist: pre-allocate buffer array in one go with the buffer list A buffer list currently takes at least three allocs and then three frees, assuming there are no re-allocs to expand. We can allocate the buffers array in one go with the list to save these additional allocs/frees in almost all common use cases, which can easily add up to a couple of hundred malloc/frees per second saved. Putting this here until 1.4 is out.
commit fbe2477fae40e546b31b8397d4ac79b5954c827b Author: Tim-Philipp Müller <tim@centricular.com> Date: Thu Jun 26 14:09:25 2014 +0100 bufferlist: pre-allocate buffer array in one go with the buffer list We can now create and free a buffer list with one slice alloc/free call in most cases, instead of one slice alloc/free for the list, one slice alloc/free for the GArray, and one malloc/free for the GArray array. In practice we know the max size of our buffer list from the start, so can avoid reallocs. https://bugzilla.gnome.org/show_bug.cgi?id=732284