From 2319431345378df679e33f14b4b0f2d78eb6ce0d Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Thu, 1 Dec 2005 23:20:22 +0000 Subject: [PATCH] improved gettimeofday() timer resolution by maintaining acceptable load Fri Dec 2 00:16:59 2005 Tim Janik * glib/gslice.c: improved gettimeofday() timer resolution by maintaining acceptable load distribution of the syscall. (slab_allocator_free_chunk): reduce minimum/single-thread magazine sizes to approximately page_size/2.5 to avoid excessive startup allocations. --- ChangeLog | 7 +++++++ ChangeLog.pre-2-10 | 7 +++++++ ChangeLog.pre-2-12 | 7 +++++++ glib/gslice.c | 6 +++--- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2cd4f35..92cdad5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Dec 2 00:16:59 2005 Tim Janik + + * glib/gslice.c: improved gettimeofday() timer resolution by maintaining + acceptable load distribution of the syscall. + (slab_allocator_free_chunk): reduce minimum/single-thread magazine sizes + to approximately page_size/2.5 to avoid excessive startup allocations. + 2005-12-01 Matthias Clasen * tests/gobject/ifacecheck.c (test_iface_base_init): Don't diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 2cd4f35..92cdad5 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +Fri Dec 2 00:16:59 2005 Tim Janik + + * glib/gslice.c: improved gettimeofday() timer resolution by maintaining + acceptable load distribution of the syscall. + (slab_allocator_free_chunk): reduce minimum/single-thread magazine sizes + to approximately page_size/2.5 to avoid excessive startup allocations. + 2005-12-01 Matthias Clasen * tests/gobject/ifacecheck.c (test_iface_base_init): Don't diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 2cd4f35..92cdad5 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,10 @@ +Fri Dec 2 00:16:59 2005 Tim Janik + + * glib/gslice.c: improved gettimeofday() timer resolution by maintaining + acceptable load distribution of the syscall. + (slab_allocator_free_chunk): reduce minimum/single-thread magazine sizes + to approximately page_size/2.5 to avoid excessive startup allocations. + 2005-12-01 Matthias Clasen * tests/gobject/ifacecheck.c (test_iface_base_init): Don't diff --git a/glib/gslice.c b/glib/gslice.c index 0cc903a..0874a88 100644 --- a/glib/gslice.c +++ b/glib/gslice.c @@ -92,7 +92,7 @@ #define SLAB_INFO_SIZE P2ALIGN (sizeof (SlabInfo) + NATIVE_MALLOC_PADDING) #define MAX_MAGAZINE_SIZE (256) /* see [3] and allocator_get_magazine_threshold() for this */ #define MIN_MAGAZINE_SIZE (4) -#define MAX_STAMP_COUNTER (13) /* distributes the load of gettimeofday() */ +#define MAX_STAMP_COUNTER (7) /* distributes the load of gettimeofday() */ #define MAX_SLAB_CHUNK_SIZE(al) (((al)->max_page_size - SLAB_INFO_SIZE) / 8) /* we want at last 8 chunks per page, see [4] */ #define MAX_SLAB_INDEX(al) (SLAB_INDEX (al, MAX_SLAB_CHUNK_SIZE (al)) + 1) #define SLAB_INDEX(al, asize) ((asize) / P2ALIGNMENT - 1) /* asize must be P2ALIGNMENT aligned */ @@ -406,14 +406,14 @@ allocator_get_magazine_threshold (Allocator *allocator, /* the magazine size calculated here has a lower bound of MIN_MAGAZINE_SIZE, * which is required by the implementation. also, for moderately sized chunks * (say >= 64 bytes), magazine sizes shouldn't be much smaller then the number - * of chunks available per page to avoid excessive traffic in the magazine + * of chunks available per page/2 to avoid excessive traffic in the magazine * cache for small to medium sized structures. * the upper bound of the magazine size is effectively provided by * MAX_MAGAZINE_SIZE. for larger chunks, this number is scaled down so that * the content of a single magazine doesn't exceed ca. 16KB. */ guint chunk_size = SLAB_CHUNK_SIZE (allocator, ix); - guint threshold = MAX (MIN_MAGAZINE_SIZE, sys_page_size / MAX (chunk_size, 64)); + guint threshold = MAX (MIN_MAGAZINE_SIZE, allocator->max_page_size / MAX (5 * chunk_size, 5 * 32)); guint contention_counter = allocator->contention_counters[ix]; if (G_UNLIKELY (contention_counter)) /* single CPU bias */ { -- 2.7.4