Commit fda8ef19 authored by nagayama15's avatar nagayama15

jemallocへの埋め込み実験を追加

parent 2e0e0053
......@@ -13,3 +13,6 @@
[submodule "example/tree/tree"]
path = example/tree/tree
url = git://github.com/execjosh/tree.git
[submodule "example/jemalloc/jemalloc"]
path = example/jemalloc/jemalloc
url = git://github.com/jemalloc/jemalloc.git
.DEFAULT_GOAL := all
BUILD_TYPE := release
#BUILD_TYPE := debug
ROOT := $(realpath ${PWD})
CD := $(realpath ${CURDIR})
......
......@@ -7,6 +7,7 @@ all:
${MAKE} -C lua all
${MAKE} -C cJSON all
${MAKE} -C tree all
${MAKE} -C jemalloc all
${MAKE} -C fizzbuzz-rs all
${MAKE} -C numguess-rs all
......@@ -17,6 +18,7 @@ test:
${MAKE} -C lua test
${MAKE} -C cJSON test
${MAKE} -C tree test
${MAKE} -C jemalloc test
${MAKE} -C fizzbuzz-rs test
${MAKE} -C numguess-rs test
......
include ../../common.mk
WATERMARK := jemalloc-watermarking
CFLAGS := -std=gnu11 -Wno-ignored-attributes -D_GNU_SOURCE -Ijemalloc/include -Iinclude
CFLAGS_debug := -O0
CFLAGS_release := -O2 -DNDEBUG
CFLAGS += ${CFLAGS_${BUILD_TYPE}}
SRCS := \
jemalloc/src/arena.c \
jemalloc/src/background_thread.c \
jemalloc/src/base.c \
jemalloc/src/bin.c \
jemalloc/src/bitmap.c \
jemalloc/src/ckh.c \
jemalloc/src/ctl.c \
jemalloc/src/div.c \
jemalloc/src/extent.c \
jemalloc/src/extent_dss.c \
jemalloc/src/extent_mmap.c \
jemalloc/src/hash.c \
jemalloc/src/hook.c \
jemalloc/src/jemalloc.c \
jemalloc/src/large.c \
jemalloc/src/log.c \
jemalloc/src/malloc_io.c \
jemalloc/src/mutex.c \
jemalloc/src/mutex_pool.c \
jemalloc/src/nstime.c \
jemalloc/src/pages.c \
jemalloc/src/prng.c \
jemalloc/src/prof.c \
jemalloc/src/rtree.c \
jemalloc/src/sc.c \
jemalloc/src/stats.c \
jemalloc/src/sz.c \
jemalloc/src/tcache.c \
jemalloc/src/test_hooks.c \
jemalloc/src/ticker.c \
jemalloc/src/tsd.c \
jemalloc/src/witness.c
OBJS := ${SRCS:jemalloc/src/%.c=${OBJ_DIR}/%.o}
OBJS_WM := ${OBJS:%.o=%-wm.o}
LLS := ${OBJS:.o=.ll}
LLS_WM := ${OBJS_WM:.o=.ll}
.PRECIOUS: ${LLS} ${LLS_WM}
all: \
${BIN_DIR}/libjemalloc.a \
${BIN_DIR}/libjemalloc-wm.a
${BIN_DIR}/libjemalloc.a: ${OBJS}
${BIN_DIR}/libjemalloc-wm.a: ${OBJS_WM}
${BIN_DIR}/%.a:
@mkdir -p ${@D}
ar rcs $@ $^
${OBJ_DIR}/%.ll: jemalloc/src/%.c
@mkdir -p ${@D}
clang -S -emit-llvm ${CFLAGS} -o $@ $<
${OBJ_DIR}/%.o: ${OBJ_DIR}/%.ll
@mkdir -p ${@D}
clang -o $@ -c $<
${OBJ_DIR}/%-wm.ll: ${OBJ_DIR}/%.ll
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -block-wm -watermark=${WATERMARK} -S -o ${@:%-wm.ll=%-block-wm.ll} $< 2> ${@:%-wm.ll=%-block-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=${WATERMARK} -S -o $@ ${@:%-wm.ll=%-block-wm.ll} 2> ${@:%-wm.ll=%-inst-wm.txt}
#ifndef JEMALLOC_PREAMBLE_H
#define JEMALLOC_PREAMBLE_H
#include "jemalloc_internal_defs.h"
#include "jemalloc/internal/jemalloc_internal_decls.h"
#ifdef JEMALLOC_UTRACE
#include <sys/ktrace.h>
#endif
#define JEMALLOC_NO_DEMANGLE
#ifdef JEMALLOC_JET
# undef JEMALLOC_IS_MALLOC
# define JEMALLOC_N(n) jet_##n
# include "jemalloc/internal/public_namespace.h"
# define JEMALLOC_NO_RENAME
# include "../jemalloc.h"
# undef JEMALLOC_NO_RENAME
#else
# define JEMALLOC_N(n) je_##n
# include "../jemalloc.h"
#endif
#if defined(JEMALLOC_OSATOMIC)
#include <libkern/OSAtomic.h>
#endif
#ifdef JEMALLOC_ZONE
#include <mach/mach_error.h>
#include <mach/mach_init.h>
#include <mach/vm_map.h>
#endif
#include "jemalloc/internal/jemalloc_internal_macros.h"
/*
* Note that the ordering matters here; the hook itself is name-mangled. We
* want the inclusion of hooks to happen early, so that we hook as much as
* possible.
*/
#ifndef JEMALLOC_NO_PRIVATE_NAMESPACE
# ifndef JEMALLOC_JET
# include "jemalloc/internal/private_namespace.h"
# else
# include "jemalloc/internal/private_namespace_jet.h"
# endif
#endif
#include "jemalloc/internal/test_hooks.h"
#ifdef JEMALLOC_DEFINE_MADVISE_FREE
# define JEMALLOC_MADV_FREE 8
#endif
static const bool config_debug =
#ifdef JEMALLOC_DEBUG
true
#else
false
#endif
;
static const bool have_dss =
#ifdef JEMALLOC_DSS
true
#else
false
#endif
;
static const bool have_madvise_huge =
#ifdef JEMALLOC_HAVE_MADVISE_HUGE
true
#else
false
#endif
;
static const bool config_fill =
#ifdef JEMALLOC_FILL
true
#else
false
#endif
;
static const bool config_lazy_lock =
#ifdef JEMALLOC_LAZY_LOCK
true
#else
false
#endif
;
static const char * const config_malloc_conf = JEMALLOC_CONFIG_MALLOC_CONF;
static const bool config_prof =
#ifdef JEMALLOC_PROF
true
#else
false
#endif
;
static const bool config_prof_libgcc =
#ifdef JEMALLOC_PROF_LIBGCC
true
#else
false
#endif
;
static const bool config_prof_libunwind =
#ifdef JEMALLOC_PROF_LIBUNWIND
true
#else
false
#endif
;
static const bool maps_coalesce =
#ifdef JEMALLOC_MAPS_COALESCE
true
#else
false
#endif
;
static const bool config_stats =
#ifdef JEMALLOC_STATS
true
#else
false
#endif
;
static const bool config_tls =
#ifdef JEMALLOC_TLS
true
#else
false
#endif
;
static const bool config_utrace =
#ifdef JEMALLOC_UTRACE
true
#else
false
#endif
;
static const bool config_xmalloc =
#ifdef JEMALLOC_XMALLOC
true
#else
false
#endif
;
static const bool config_cache_oblivious =
#ifdef JEMALLOC_CACHE_OBLIVIOUS
true
#else
false
#endif
;
/*
* Undocumented, for jemalloc development use only at the moment. See the note
* in jemalloc/internal/log.h.
*/
static const bool config_log =
#ifdef JEMALLOC_LOG
true
#else
false
#endif
;
#if defined(_WIN32) || defined(JEMALLOC_HAVE_SCHED_GETCPU)
/* Currently percpu_arena depends on sched_getcpu. */
#define JEMALLOC_PERCPU_ARENA
#endif
static const bool have_percpu_arena =
#ifdef JEMALLOC_PERCPU_ARENA
true
#else
false
#endif
;
/*
* Undocumented, and not recommended; the application should take full
* responsibility for tracking provenance.
*/
static const bool force_ivsalloc =
#ifdef JEMALLOC_FORCE_IVSALLOC
true
#else
false
#endif
;
static const bool have_background_thread =
#ifdef JEMALLOC_BACKGROUND_THREAD
true
#else
false
#endif
;
#endif /* JEMALLOC_PREAMBLE_H */
This diff is collapsed.
This diff is collapsed.
Subproject commit bbe8e6a9097203c7b29140b5410c787a6e204593
......@@ -54,6 +54,8 @@ echo "==== cJSON block-wm ===="
h1 obj/$1/example/cJSON/*-block-wm.txt
echo "==== tree block-wm ===="
h1 obj/$1/example/tree/*-block-wm.txt
echo "==== jemalloc block-wm ===="
h1 obj/$1/example/jemalloc/*-block-wm.txt
echo "==== fizzbuzz-rs block-wm ===="
h1 obj/$1/example/fizzbuzz-rs/*-block-wm.txt
echo "==== numguess-rs block-wm ===="
......@@ -69,6 +71,8 @@ echo "==== cJSON inst-wm ===="
h2 obj/$1/example/cJSON/*-inst-wm.txt
echo "==== tree inst-wm ===="
h2 obj/$1/example/tree/*-inst-wm.txt
echo "==== jemalloc inst-wm ===="
h2 obj/$1/example/jemalloc/*-inst-wm.txt
echo "==== fizzbuzz-rs inst-wm ===="
h2 obj/$1/example/fizzbuzz-rs/*-inst-wm.txt
echo "==== numguess-rs inst-wm ===="
......
......@@ -26,3 +26,4 @@ h example/zlib/zlib/*.c
h example/lua/lua/*.c
h example/cJSON/cJSON/cJSON.c example/cJSON/cJSON/cJSON_Utils.c
h example/tree/tree/*.c
h `ls example/jemalloc/jemalloc/src/*.c | awk -F 'example/jemalloc/jemalloc/src/test_hooks.c' -F 'example/jemalloc/jemalloc/src/zone.c' '{print $NF}'`
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment