mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 15:47:01 +02:00
Each thread now keeps the last ~512 kB of freed objects into a local cache. There are some heuristics involved so that a specific pool cannot use more than 1/8 of the total cache in number of objects. Tests have shown that 512 kB is an optimal size on a 24-thread test running on a dual-socket machine, resulting in an overall 7.5% performance increase and a cache miss ratio reducing from 19.2 to 17.7%. Anyway it seems pointless to keep more than an L2 cache, which probably explains why sizes between 256 and 512 kB are optimal. Cached objects appear in two lists, one per pool and one LRU to help with fair eviction. Currently there is no way to check each thread's cache state nor to flush it. This cache cannot be disabled and is enabled as soon as the lockless pools are enabled (i.e.: threads are enabled, no pool debugging is in use and the CPU supports a double word CAS).
76 lines
2.6 KiB
C
76 lines
2.6 KiB
C
/*
|
|
* include/common/config.h
|
|
* This files contains most of the user-configurable settings.
|
|
*
|
|
* Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
* exclusively.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef _COMMON_CONFIG_H
|
|
#define _COMMON_CONFIG_H
|
|
|
|
#include <common/compiler.h>
|
|
#include <common/compat.h>
|
|
#include <common/defaults.h>
|
|
|
|
/* this reduces the number of calls to select() by choosing appropriate
|
|
* sheduler precision in milliseconds. It should be near the minimum
|
|
* time that is needed by select() to collect all events. All timeouts
|
|
* are rounded up by adding this value prior to pass it to select().
|
|
*/
|
|
#define SCHEDULER_RESOLUTION 9
|
|
|
|
/* CONFIG_HAP_MEM_OPTIM
|
|
* This enables use of memory pools instead of malloc()/free(). There
|
|
* is no reason to disable it, except perhaps for rare debugging.
|
|
*/
|
|
#ifndef CONFIG_HAP_NO_MEM_OPTIM
|
|
# define CONFIG_HAP_MEM_OPTIM
|
|
#endif /* CONFIG_HAP_NO_MEM_OPTIM */
|
|
|
|
#ifdef USE_THREAD
|
|
#define THREAD_LOCAL __thread
|
|
#else
|
|
#define THREAD_LOCAL
|
|
#endif
|
|
|
|
/* Some architectures have a double-word CAS, sometimes even dual-8 bytes */
|
|
#if defined(__x86_64__) || defined (__aarch64__)
|
|
#define HA_HAVE_CAS_DW
|
|
#define HA_CAS_IS_8B
|
|
#elif defined(__arm__) && (defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__))
|
|
#define HA_HAVE_CAS_DW
|
|
#endif
|
|
|
|
/* On architectures supporting threads and double-word CAS, we can implement
|
|
* lock-less memory pools. This isn't supported for debugging modes however.
|
|
*/
|
|
#if defined(USE_THREAD) && defined(HA_HAVE_CAS_DW) && !defined(DEBUG_NO_LOCKLESS_POOLS) && !defined(DEBUG_UAF)
|
|
#define CONFIG_HAP_LOCKLESS_POOLS
|
|
#ifndef CONFIG_HAP_POOL_CACHE_SIZE
|
|
#define CONFIG_HAP_POOL_CACHE_SIZE 524288
|
|
#endif
|
|
#endif
|
|
|
|
/* CONFIG_HAP_INLINE_FD_SET
|
|
* This makes use of inline FD_* macros instead of calling equivalent
|
|
* functions. Benchmarks on a Pentium-M show that using functions is
|
|
* generally twice as fast. So it's better to keep this option unset.
|
|
*/
|
|
//#undef CONFIG_HAP_INLINE_FD_SET
|
|
|
|
#endif /* _COMMON_CONFIG_H */
|