From ae6df065ed699278db5a219650cd0037dac2adec Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sun, 13 Jan 2008 00:20:44 +0000 Subject: r15890@tombo: nickm | 2008-01-12 17:19:51 -0500 Add a --disable-buffer-freelists configure argument to build without buffer RAM chunk freelists, so we can benchmark the impact of this. svn:r13121 --- src/or/buffers.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src') diff --git a/src/or/buffers.c b/src/or/buffers.c index 8d8059e1fd..57ebc19c63 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -95,6 +95,7 @@ chunk_repack(chunk_t *chunk) chunk->data = &chunk->mem[0]; } +#ifdef ENABLE_BUF_FREELISTS /** A freelist of chunks. */ typedef struct chunk_freelist_t { size_t alloc_size; /**< What size chunks does this freelist hold? */ @@ -188,6 +189,24 @@ chunk_new_with_alloc_size(size_t alloc) ch->data = &ch->mem[0]; return ch; } +#else +static void +chunk_free(chunk_t *chunk) +{ + tor_free(chunk); +} +static INLINE chunk_t * +chunk_new_with_alloc_size(size_t alloc) +{ + chunk_t *ch; + ch = tor_malloc_roundup(&alloc); + ch->next = NULL; + ch->datalen = 0; + ch->memlen = CHUNK_SIZE_WITH_ALLOC(alloc); + ch->data = &ch->mem[0]; + return ch; +} +#endif /** Allocate a new chunk with memory size of sz. */ #define chunk_new_with_capacity(sz) \ @@ -221,6 +240,7 @@ static INLINE size_t preferred_chunk_size(size_t target) { /* XXXX020 use log2 code, maybe. */ + /* XXXX020 or make sizing code more fine-grained! */ size_t sz = MIN_CHUNK_ALLOC; while (CHUNK_SIZE_WITH_ALLOC(sz) < target) { sz <<= 1; @@ -233,6 +253,7 @@ preferred_chunk_size(size_t target) void buf_shrink_freelists(int free_all) { +#ifdef ENABLE_BUF_FREELISTS int i; for (i = 0; freelists[i].alloc_size; ++i) { int slack = freelists[i].slack; @@ -267,6 +288,9 @@ buf_shrink_freelists(int free_all) freelists[i].lowest_length = freelists[i].cur_length; assert_freelist_ok(&freelists[i]); } +#else + (void) free_all; +#endif } /** Describe the current status of the freelists at log level severity. @@ -274,6 +298,7 @@ buf_shrink_freelists(int free_all) void buf_dump_freelist_sizes(int severity) { +#ifdef ENABLE_BUF_FREELISTS int i; log(severity, LD_MM, "====== Buffer freelists:"); for (i = 0; freelists[i].alloc_size; ++i) { @@ -290,6 +315,9 @@ buf_dump_freelist_sizes(int severity) } log(severity, LD_MM, U64_FORMAT" allocations in non-freelist sizes", U64_PRINTF_ARG(n_freelist_miss)); +#else + (void)severity; +#endif } /** Magic value for buf_t.magic, to catch pointer errors. */ @@ -1612,6 +1640,7 @@ assert_buf_ok(buf_t *buf) } } +#ifdef ENABLE_BUF_FREELISTS /** Log an error and exit if fl is corrupted. */ static void @@ -1629,4 +1658,5 @@ assert_freelist_ok(chunk_freelist_t *fl) tor_assert(n >= fl->lowest_length); tor_assert(n <= fl->max_length); } +#endif -- cgit v1.2.3-54-g00ecf