From 33cbf3a9c27bd1aa271c145486062164ce2bc36e Mon Sep 17 00:00:00 2001 From: Maxim Sobolev Date: Thu, 2 Nov 2006 21:59:45 +0000 Subject: [PATCH] Add new WITH_SYSTEM_MALLOC knob, which results in system malloc being used for memory allocation instead of SER's own one. Stress tests failed to show any considerable difference in the performance, while system version provides much better scalability and in future should also provide some benefits on SMP systems. --- net/ser/Makefile | 6 +++++- net/ser/files/patch-Makefile.defs | 17 +++++++++++++++++ net/ser/files/patch-mem::mem.h | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 net/ser/files/patch-mem::mem.h diff --git a/net/ser/Makefile b/net/ser/Makefile index f6903a898fe5..3a389f78e79c 100644 --- a/net/ser/Makefile +++ b/net/ser/Makefile @@ -7,7 +7,7 @@ PORTNAME= ser PORTVERSION= 0.9.6 -PORTREVISION= 3 +PORTREVISION= 4 CATEGORIES= net MASTER_SITES= http://download.berlios.de/ser/ \ http://download2.berlios.de/ser/ @@ -30,6 +30,10 @@ MANCOMPRESSED= no .include +.if !defined(WITH_SYSTEM_MALLOC) +MAKE_ENV+= "extra_defs=-DF_MALLOC -DPKG_MALLOC" +.endif + .if !defined(WITHOUT_MYSQL) USE_MYSQL= yes PLIST_SUB+= MYSQL="" diff --git a/net/ser/files/patch-Makefile.defs b/net/ser/files/patch-Makefile.defs index 5a72b5cc5f15..f8b6bc9538d4 100644 --- a/net/ser/files/patch-Makefile.defs +++ b/net/ser/files/patch-Makefile.defs @@ -19,6 +19,23 @@ $FreeBSD$ #set some vars from the environment (and not make builtins) CC := $(shell echo "$${CC}") +@@ -321,14 +322,14 @@ + -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \ + -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \ + -DCFG_DIR='"$(cfg-target)"'\ +- -DPKG_MALLOC \ + -DSHM_MEM -DSHM_MMAP \ + -DDNS_IP_HACK \ + -DUSE_IPV6 \ + -DUSE_MCAST \ + -DUSE_TCP \ + -DDISABLE_NAGLE \ +- -DF_MALLOC \ ++ #-DPKG_MALLOC \ ++ #-DF_MALLOC \ + #-DDBG_QM_MALLOC \ + #-DDBG_F_MALLOC \ + #-DNO_DEBUG \ @@ -464,8 +465,8 @@ found_lock_method=yes endif diff --git a/net/ser/files/patch-mem::mem.h b/net/ser/files/patch-mem::mem.h new file mode 100644 index 000000000000..81e7c3d59e99 --- /dev/null +++ b/net/ser/files/patch-mem::mem.h @@ -0,0 +1,22 @@ + +$FreeBSD$ + +--- mem/mem.h.orig ++++ mem/mem.h +@@ -122,9 +122,13 @@ + #else + # include + # define pkg_malloc(s) \ +- ( { void *v; v=malloc((s)); \ +- DBG("malloc %p size %d end %p\n", v, s, (char*)v+(s));\ +- v; } ) ++ ( { void *____v123; ____v123=malloc((s)); \ ++ DBG("malloc %p size %lu end %p\n", ____v123, (unsigned long)(s), (char*)____v123+(s));\ ++ ____v123; } ) ++# define pkg_realloc(p, s) \ ++ ( { void *____v123; ____v123=realloc(p, s); \ ++ DBG("realloc %p size %lu end %p\n", ____v123, (unsigned long)(s), (char*)____v123+(s));\ ++ ____v123; } ) + # define pkg_free(p) do{ DBG("free %p\n", (p)); free((p)); }while(0); + # define pkg_status() + #endif