1bc68bb02SChiyoung Seo/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2bc68bb02SChiyoung Seo/*
3bc68bb02SChiyoung Seo *     Copyright 2010 Couchbase, Inc
4bc68bb02SChiyoung Seo *
5bc68bb02SChiyoung Seo *   Licensed under the Apache License, Version 2.0 (the "License");
6bc68bb02SChiyoung Seo *   you may not use this file except in compliance with the License.
7bc68bb02SChiyoung Seo *   You may obtain a copy of the License at
8bc68bb02SChiyoung Seo *
9bc68bb02SChiyoung Seo *       http://www.apache.org/licenses/LICENSE-2.0
10bc68bb02SChiyoung Seo *
11bc68bb02SChiyoung Seo *   Unless required by applicable law or agreed to in writing, software
12bc68bb02SChiyoung Seo *   distributed under the License is distributed on an "AS IS" BASIS,
13bc68bb02SChiyoung Seo *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14bc68bb02SChiyoung Seo *   See the License for the specific language governing permissions and
15bc68bb02SChiyoung Seo *   limitations under the License.
16bc68bb02SChiyoung Seo */
17bc68bb02SChiyoung Seo
18ee50db50SJung-Sang Ahn#ifndef _JSAHN_OPTION_H
19ee50db50SJung-Sang Ahn#define _JSAHN_OPTION_H
20ee50db50SJung-Sang Ahn
21e6449f52SJung-Sang Ahn//#include "mempool.h"
22ee50db50SJung-Sang Ahn
23393e6cadSGihwan Oh#define SEQNUM_NOT_USED (UINT64_C(0xffffffffffffffff))
2413fd7d20SJung-Sang Ahn#define DEFAULT_KVS_NAME "default"
2502cf2f57SJung-Sang Ahn
268a19c40bSJung-Sang Ahn#define __FDB_BCACHE_USE
27dd2f9e13SJung-Sang Ahn#ifdef __FDB_BCACHE_USE
287be5b070SJung-Sang Ahn    //#define __FDB_SORTED_COMPACTION
29dd2f9e13SJung-Sang Ahn#endif
30dd2f9e13SJung-Sang Ahn#define FDB_SECTOR_SIZE (512)
31762e6a5dSJung-Sang Ahn
32d5c88c55SJung-Sang Ahn//#define DOCIO_BLOCK_ALIGN
33505f35b8SJung-Sang Ahn#define DOCIO_LEN_STRUCT_ALIGN
34762e6a5dSJung-Sang Ahn
359e14d68eSJung-Sang Ahn//#define __RAW_BLOCK
36ee50db50SJung-Sang Ahn
37d25f8d6dSJung-Sang Ahn#define __CRC32
389ceccb2cSJung-Sang Ahn#ifdef __CRC32
399ceccb2cSJung-Sang Ahn    #define BTREE_CRC_OFFSET (8)
401d727293SJung-Sang Ahn    #define BTREE_CRC_FIELD_LEN (8)
4100a9594fSJung-Sang Ahn    #define BTREE_LEVEL_OFFSET (2)
424f2ebc0aSJung-Sang Ahn    //#define __CHECKSUM_ADLER32
439ceccb2cSJung-Sang Ahn#endif
44fa5a43c0SJung-Sang Ahn
45ee50db50SJung-Sang Ahn#define __BIT_CMP
46ee50db50SJung-Sang Ahn
476d79432aSJung-Sang Ahn#define __ENDIAN_SAFE
486d79432aSJung-Sang Ahn
49bb05885fSJung-Sang Ahn//#define __DEBUG_FDB
50ee50db50SJung-Sang Ahn//#define __DEBUG_WAL
51ee50db50SJung-Sang Ahn//#define __DEBUG_HBTRIE
52ee50db50SJung-Sang Ahn//#define __DEBUG_BTREE
53ee50db50SJung-Sang Ahn//#define __DEBUG_BTREEBLOCK
54ee50db50SJung-Sang Ahn//#define __DEBUG_BCACHE
55ee50db50SJung-Sang Ahn//#define __DEBUG_FILEMGR
56dd2f9e13SJung-Sang Ahn//#define __DEBUG_COUCHBENCH
57ee50db50SJung-Sang Ahn
58bb05885fSJung-Sang Ahn#define FDB_BLOCKSIZE (4096)
5969467020SChiyoung Seo#define FDB_WAL_NBUCKET (4099) // a prime number
604a0379f5SJung-Sang Ahn#define FDB_MAX_FILENAME_LEN (1024)
61d32401daSJung-Sang Ahn#define FDB_MAX_KVINS_NAME_LEN (65536)
629ceccb2cSJung-Sang Ahn#define FDB_WAL_THRESHOLD (4*1024)
638469cffeSChiyoung Seo#define FDB_COMP_BUF_MINSIZE (67108864) // 64 MB, 8M offsets
6414f97ccfSJung-Sang Ahn#define FDB_COMP_BUF_MAXSIZE (1073741824) // 1 GB, 128M offsets
655827abeaSJung-Sang Ahn// Minimum window size for compaction sorting window, 128K offsets.
665827abeaSJung-Sang Ahn#define FDB_COMP_WINDOW_MINSIZE (131072)
6735745362SChiyoung Seo#define FDB_COMP_BATCHSIZE (131072) // 128K docs
685827abeaSJung-Sang Ahn// Minimum batch size for compaction, 1024 docs.
695827abeaSJung-Sang Ahn#define FDB_COMP_BATCHSIZE_MIN (1024)
70818018a1SChiyoung Seo#define FDB_COMP_MOVE_UNIT (134217728) // 128 MB
71d24dc9ccSJung-Sang Ahn#define FDB_COMP_RATIO_MIN (40) // 40% (writer speed / compactor speed)
72d24dc9ccSJung-Sang Ahn#define FDB_COMP_RATIO_MAX (60) // 60% (writer speed / compactor speed)
73d24dc9ccSJung-Sang Ahn#define FDB_COMP_PROB_UNIT_INC (5) // 5% (probability delta unit for increase)
74d24dc9ccSJung-Sang Ahn#define FDB_COMP_PROB_UNIT_DEC (5) // 5% (probability delta unit for decrease)
75bb71615fSChiyoung Seo
76bb71615fSChiyoung Seo// full compaction internval in secs when the circular block reusing is enabled
77bb71615fSChiyoung Seo#define FDB_COMPACTOR_SLEEP_DURATION (28800)
7847fac250SJung-Sang Ahn#define FDB_DEFAULT_COMPACTION_THRESHOLD (30)
79bb71615fSChiyoung Seo
804cdca91eSSundar Sridharan#define FDB_BGFLUSHER_SLEEP_DURATION (2)
814cdca91eSSundar Sridharan#define FDB_BGFLUSHER_DIRTY_THRESHOLD (1024) //if more than this 4MB dirty
824cdca91eSSundar Sridharan                                             // wake up any sleeping bgflusher
83bb05885fSJung-Sang Ahn
8469467020SChiyoung Seo#define BCACHE_NBUCKET (4099) // a prime number
8569467020SChiyoung Seo#define BCACHE_NDICBUCKET (4099) // a prime number
8665a4da43SJung-Sang Ahn#define BCACHE_FLUSH_UNIT (1048576) // 1MB
8700a9594fSJung-Sang Ahn#define BCACHE_EVICT_UNIT (1)
885257ddacSChiyoung Seo#define BCACHE_MEMORY_THRESHOLD (0.8) // 80% of physical RAM
8900a9594fSJung-Sang Ahn#define __BCACHE_SECOND_CHANCE
908e93bc7bSJung-Sang Ahn
916a3a5c2dSJung-Sang Ahn#define FILEMGR_PREFETCH_UNIT (4194304) // 4MB
92604393d9SSundar Sridharan#define FILEMGR_RESIDENT_THRESHOLD (0.9) // 90 % of file is in buffer cache
9330a02785SJung-Sang Ahn#define __FILEMGR_DATA_PARTIAL_LOCK
9430a02785SJung-Sang Ahn//#define __FILEMGR_DATA_MUTEX_LOCK
95bb05885fSJung-Sang Ahn
96f0b1bf77SJung-Sang Ahn#define SB_DEFAULT_NUM_SUPERBLOCKS (4) // 4 superblocks for crash recovery
97f0b1bf77SJung-Sang Ahn#define SB_MAX_BITMAP_DOC_SIZE (1048576) // 1MB, 4M bitmaps per doc
98f0b1bf77SJung-Sang Ahn// Minimum file size for the condition that block reusing is triggered
99f0b1bf77SJung-Sang Ahn#define SB_MIN_BLOCK_REUSING_FILESIZE (16777216) // 16MB
100f0b1bf77SJung-Sang Ahn// Period that superblock is written into the file
101f0b1bf77SJung-Sang Ahn#define SB_SYNC_PERIOD (4194304) // sync for every 4MB update
102f0b1bf77SJung-Sang Ahn// Time limit for reusable block reclaim
103f0b1bf77SJung-Sang Ahn#define SB_RECLAIM_TIMELIMIT (100000) // 100 ms
10427376f3bSJung-Sang Ahn// Threshold for pre-reclaiming
10527376f3bSJung-Sang Ahn#define SB_PRE_RECLAIM_RATIO (10) // 10 %
106f0b1bf77SJung-Sang Ahn
107478c2f10SJung-Sang Ahn#define __BTREEBLK_BLOCKPOOL
1080ebdd56fSJung-Sang Ahn#define __BTREEBLK_SUBBLOCK
109d32401daSJung-Sang Ahn//#define __BTREEBLK_READ_TREE // not used now, for future use
110d32401daSJung-Sang Ahn#define BTREEBLK_AGE_LIMIT (10)
1110ebdd56fSJung-Sang Ahn#define BTREEBLK_MIN_SUBBLOCK (128)
112478c2f10SJung-Sang Ahn//#define __BTREEBLK_CACHE
1139ceccb2cSJung-Sang Ahn#ifdef __BTREEBLK_CACHE
1149ceccb2cSJung-Sang Ahn    #define BTREEBLK_CACHE_LIMIT (8)
1159ceccb2cSJung-Sang Ahn#endif
1169ceccb2cSJung-Sang Ahn
1179ceccb2cSJung-Sang Ahn//#define __UTREE
1189ceccb2cSJung-Sang Ahn#ifdef __UTREE
1199ceccb2cSJung-Sang Ahn    #define __UTREE_HEADER_SIZE (16)
1209ceccb2cSJung-Sang Ahn    #undef BTREE_CRC_OFFSET
1219ceccb2cSJung-Sang Ahn    #define BTREE_CRC_OFFSET (__UTREE_HEADER_SIZE+8)
1229ceccb2cSJung-Sang Ahn#endif
12380e69aceSJung-Sang Ahn
124b84b312aSChiyoung Seo// WAL parition sizes
12569467020SChiyoung Seo#define DEFAULT_NUM_WAL_PARTITIONS (11) // a prime number
126b84b312aSChiyoung Seo#define MAX_NUM_WAL_PARTITIONS (512)
127b84b312aSChiyoung Seo
12869467020SChiyoung Seo// Buffer cache partition size
12969467020SChiyoung Seo#define DEFAULT_NUM_BCACHE_PARTITIONS (11) // a prime number
13069467020SChiyoung Seo#define MAX_NUM_BCACHE_PARTITIONS (512)
13169467020SChiyoung Seo
132c6c3d274SChiyoung Seo// Asynchronous I/O queue depth
133c6c3d274SChiyoung Seo#define ASYNC_IO_QUEUE_DEPTH (64)
134c6c3d274SChiyoung Seo
135c40231deSChiyoung Seo// Number of daemon compactor threads
136c40231deSChiyoung Seo#define DEFAULT_NUM_COMPACTOR_THREADS (4)
137c40231deSChiyoung Seo#define MAX_NUM_COMPACTOR_THREADS (128)
138c40231deSChiyoung Seo
13990621440SSundar Sridharan#define DEFAULT_NUM_BGFLUSHER_THREADS (2)
1404cdca91eSSundar Sridharan#define MAX_NUM_BGFLUSHER_THREADS (64)
141ee50db50SJung-Sang Ahn#endif
142