cvs: pecl /apc apc_sma.c
| From: | Rasmus Lerdorf | Date: | Sat, 25 Feb 2006 06:48:13 +0000 |
| Subject: | cvs: pecl /apc apc_sma.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-5264@lists.php.net to get a copy of this message | ||
rasmus Sat Feb 25 06:48:13 2006 UTC
Modified files:
/pecl/apc apc_sma.c
Log:
Ok, rounding up to the next power of 2 used a crazy amount of extra
memory and it made no sense considering the 128 minimum split limit.
So round up the next 128 byte boundary instead. Should still decrease
fragmentation by quite a bit, without using crazy amounts of memory.
http://cvs.php.net/viewcvs.cgi/pecl/apc/apc_sma.c?r1=1.32&r2=1.33&diff_format=u
Index: pecl/apc/apc_sma.c
diff -u pecl/apc/apc_sma.c:1.32 pecl/apc/apc_sma.c:1.33
--- pecl/apc/apc_sma.c:1.32 Sat Feb 25 01:49:12 2006
+++ pecl/apc/apc_sma.c Sat Feb 25 06:48:13 2006
@@ -26,7 +26,7 @@
*/
-/* $Id: apc_sma.c,v 1.32 2006/02/25 01:49:12 rasmus Exp $ */
+/* $Id: apc_sma.c,v 1.33 2006/02/25 06:48:13 rasmus Exp $ */
#include "apc_sma.h"
#include "apc.h"
@@ -45,7 +45,7 @@
#define UNLOCK(c) { apc_lck_unlock(c); HANDLE_UNBLOCK_INTERRUPTIONS(); }
/* }}} */
-enum { POWER_OF_TWO_BLOCKSIZE=1 }; /* force allocated blocks to 2^n? */
+enum { POWER_OF_TWO_BLOCKSIZE=0 }; /* force allocated blocks to 2^n? */
enum { DEFAULT_NUMSEG=1, DEFAULT_SEGSIZE=30*1024*1024 };
@@ -116,7 +116,14 @@
#endif
realsize = p + 1;
} else {
- realsize = size;
+ /* Probably makes more sense to just round up to the next 128 byte boundary */
+ size_t p = size - 1;
+#if SIZEOF_INT == 8
+ p&=0xffffffffffffff80; p+=0x80;
+#else
+ p&=0xffffff80; p+=0x80;
+#endif
+ realsize = p;
}
}
realsize = alignword(max(realsize + alignword(sizeof(int)), sizeof(block_t)));
@@ -161,7 +168,7 @@
/* update the block header */
header->avail -= realsize;
- if (cur->size == realsize || ((cur->size - realsize) < 128)) {
+ if (cur->size == realsize || ((cur->size - realsize) < 64)) {
/* cur is a perfect fit for realsize; just unlink it */
prv->next = cur->next;
}