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 116805 - glib2 scales badly on SMP systems
glib2 scales badly on SMP systems
Status: RESOLVED DUPLICATE of bug 118439
Product: glib
Classification: Platform
Component: general
2.2.x
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2003-07-06 09:10 UTC by Balazs Scheidler
Modified: 2011-02-18 16:13 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
make GString use a per-thread GMemChunk for allocation to avoid locking (2.18 KB, patch)
2003-07-06 09:11 UTC, Balazs Scheidler
needs-work Details | Review

Description Balazs Scheidler 2003-07-06 09:10:40 UTC
We are using glib in a massively multithreaded application, and some parts
of GLib scales poorly when more than a single processor is installed in the
system.

We first identified the GString mem_chunk, more precisely the lock protecting 
that mem_chunk to be a bottleneck.

The attached patch is a quick&dirty workaround which uses a per-thread
memchunk, thus avoids locking. A better solution would be to make GMemChunk
reentrant and move locking to lower levels.
Comment 1 Balazs Scheidler 2003-07-06 09:11:36 UTC
Created attachment 18071 [details] [review]
make GString use a per-thread GMemChunk for allocation to avoid locking
Comment 2 Balazs Scheidler 2003-07-07 08:40:32 UTC
Please forget the patch, as more serious testing revealed that it does
not work when a g_string_new and g_string_free is called from
different threads.
Comment 3 Matthias Clasen 2003-07-25 08:37:27 UTC
Does compiling glib with --disable-mem-pools improve the scalability ?
Comment 4 Balazs Scheidler 2003-07-25 08:49:09 UTC
scalability improves, but performance drops for one processor.

and by-the-way this configuration leaks memory (as the GMemPools do
not free anything in this case)
Comment 5 Matthias Clasen 2003-07-25 21:38:41 UTC
Are you maybe confusing DISABLE_MEM_POOLS with G_ALLOC_ONLY ?
If you're compiling glib with --disable-mem-pools, 
g_mem_chunk_alloc()/g_mem_chunk_free() directly map to
g_malloc()/g_free(), so stuff should definitively be freed in this case.
Comment 6 Balazs Scheidler 2003-07-27 14:59:13 UTC
I don't confuse those. GHashTable for instance uses G_ALLOC_ONLY
GMemPools and never calls g_mem_chunk_free, but assumes that
g_mem_chunk_destroy frees all allocated chunks, but with
DISABLE_MEM_POOLS defined this does not happen.

And another btw why do nearly all the GMemChunk users (GList, GTree
etc) have their own free lists? This functionality is implemented by
GMemChunks as well. This seems to be a duplication to me.
Comment 7 Soren Sandmann Pedersen 2003-07-28 14:29:25 UTC
bug 118439 is related to this
Comment 8 Matthias Clasen 2005-09-13 15:24:40 UTC
I think we should dup this to 118439, we only need one bug about fixing the
memory system

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