GNOME Bugzilla – Bug 169389
[PATCH] make memchunks use posix_memalign, if available
Last modified: 2011-02-18 16:13:57 UTC
Version details: CVS HEAD Distribution/Version: Debian sid The attached patch, while retaining ABI/API, adds a configure option (enabled by default) which enables the use of posix_memalign(), if available on the system, by the memchunk code. This speeds up G_ALLOC_AND_FREE memchunks; on my system, memchunks were outperformed by glibc's malloc/free before applying the patch; after applying the patch, memchunks are a faster. A simple benchmark is included in the patch.
Created attachment 38332 [details] [review] Patch to implement posix_memalign() support in memchunks You'll need memchunk-speed.c also (CVS sucks, doesn't allow generating patches with new files).
Created attachment 38333 [details] Simple benchmark of memchunks vs. plain malloc/free
Comment on attachment 38332 [details] [review] Patch to implement posix_memalign() support in memchunks I think you have to explicitly call free() for the pointer allocated by posix_memalign() since, as far as I know, g_free() is free to use any custom allocator.
This is true. I'll post an updated patch, which also reduces the number of #ifdefs later today or tommorrow.
> (CVS sucks, doesn't allow generating patches with new files) It sucks but: cvs diff -N
>> (CVS sucks, doesn't allow generating patches with new files) >> > It sucks but: cvs diff -N > It seems that only works for already-added files, and for adding files you need write access (not being distributed is what makes both CVS and SVN suck IMO).
> cvs diff -N > > It seems that only works for already-added files, and for adding files you need > write access OK, sorry: cvsdo add new-file;cvs diff -N cvsdo(1) from cvsutils from: http://www.red-bean.com/cvsutils/ A bit offtopic here, though.
Any news on this ?
Sorry, i've not yet come around to improve the patch, but I'll likely find the needed 15 minutes this weekend ;).
Created attachment 39631 [details] [review] Improved patch implementing posix_memalign() support for memchunks This patch reduces the number of newly-introduced #ifdefs and fixes the freeing of mem areas, as pointed out by Tommi Komulainen (#3).
This conflicts with the patch in bug 118439, which replaces GMemChunk by a new implementation.
Why not using mmap ? mmap would also provide align memory and would be able to return memory to the system, no ?
See the extensive discussion in bug 118439
*** This bug has been marked as a duplicate of 118439 ***