After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 169389 - [PATCH] make memchunks use posix_memalign, if available
[PATCH] make memchunks use posix_memalign, if available
Status: RESOLVED DUPLICATE of bug 118439
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2005-03-06 15:38 UTC by Andreas Rottmann
Modified: 2011-02-18 16:13 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
Patch to implement posix_memalign() support in memchunks (10.22 KB, patch)
2005-03-06 15:47 UTC, Andreas Rottmann
needs-work Details | Review
Simple benchmark of memchunks vs. plain malloc/free (1.94 KB, text/x-csrc)
2005-03-06 15:48 UTC, Andreas Rottmann
  Details
Improved patch implementing posix_memalign() support for memchunks (14.54 KB, patch)
2005-04-03 13:27 UTC, Andreas Rottmann
none Details | Review

Description Andreas Rottmann 2005-03-06 15:38:55 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.
Comment 1 Andreas Rottmann 2005-03-06 15:47:38 UTC
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).
Comment 2 Andreas Rottmann 2005-03-06 15:48:56 UTC
Created attachment 38333 [details]
Simple benchmark of memchunks vs. plain malloc/free
Comment 3 Tommi Komulainen 2005-03-06 16:20:59 UTC
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.
Comment 4 Andreas Rottmann 2005-03-06 17:04:40 UTC
This is true. I'll post an updated patch, which also reduces the number of
#ifdefs later today or tommorrow.
Comment 5 Jan Kratochvil 2005-03-07 07:54:41 UTC
> (CVS sucks, doesn't allow generating patches with new files)

It sucks but: cvs diff -N
Comment 6 Andreas Rottmann 2005-03-07 11:08:33 UTC
>> (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).
Comment 7 Jan Kratochvil 2005-03-07 14:55:37 UTC
> 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.
Comment 8 Matthias Clasen 2005-03-31 13:08:30 UTC
Any news on this ?
Comment 9 Andreas Rottmann 2005-03-31 20:32:09 UTC
Sorry, i've not yet come around to improve the patch, but I'll likely find the
needed 15 minutes this weekend ;).
Comment 10 Andreas Rottmann 2005-04-03 13:27:47 UTC
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).
Comment 11 Matthias Clasen 2005-04-05 04:20:39 UTC
This conflicts with the patch in bug 118439, which replaces GMemChunk by a new
implementation.
Comment 12 Benoît Dejean 2005-08-01 11:16:07 UTC
Why not using mmap ? mmap would also provide align memory and would be able to
return memory to the system, no ?
Comment 13 Matthias Clasen 2005-08-01 13:13:06 UTC
See the extensive discussion in bug 118439
Comment 14 Tim Janik 2005-12-02 10:38:15 UTC

*** This bug has been marked as a duplicate of 118439 ***