1 /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  *     Copyright 2010 Couchbase, Inc
4  *
5  *   Licensed under the Apache License, Version 2.0 (the "License");
6  *   you may not use this file except in compliance with the License.
7  *   You may obtain a copy of the License at
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *   Unless required by applicable law or agreed to in writing, software
12  *   distributed under the License is distributed on an "AS IS" BASIS,
13  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *   See the License for the specific language governing permissions and
15  *   limitations under the License.
16  */
17 
18 #ifndef _JSAHN_OPTION_H
19 #define _JSAHN_OPTION_H
20 
21 //#include "mempool.h"
22 
23 #define SEQNUM_NOT_USED (UINT64_C(0xffffffffffffffff))
24 #define DEFAULT_KVS_NAME "default"
25 
26 #define __FDB_BCACHE_USE
27 #ifdef __FDB_BCACHE_USE
28     //#define __FDB_SORTED_COMPACTION
29 #endif
30 #define FDB_SECTOR_SIZE (512)
31 
32 //#define DOCIO_BLOCK_ALIGN
33 #define DOCIO_LEN_STRUCT_ALIGN
34 
35 //#define __RAW_BLOCK
36 
37 #define __CRC32
38 #ifdef __CRC32
39     #define BTREE_CRC_OFFSET (8)
40     #define BTREE_CRC_FIELD_LEN (8)
41     #define BTREE_LEVEL_OFFSET (2)
42     //#define __CHECKSUM_ADLER32
43 #endif
44 
45 #define __BIT_CMP
46 
47 #define __ENDIAN_SAFE
48 
49 //#define __DEBUG_FDB
50 //#define __DEBUG_WAL
51 //#define __DEBUG_HBTRIE
52 //#define __DEBUG_BTREE
53 //#define __DEBUG_BTREEBLOCK
54 //#define __DEBUG_BCACHE
55 //#define __DEBUG_FILEMGR
56 //#define __DEBUG_COUCHBENCH
57 
58 #define FDB_BLOCKSIZE (4096)
59 #define FDB_WAL_NBUCKET (4099) // a prime number
60 #define FDB_MAX_FILENAME_LEN (1024)
61 #define FDB_MAX_KVINS_NAME_LEN (65536)
62 #define FDB_WAL_THRESHOLD (4*1024)
63 #define FDB_COMP_BUF_MINSIZE (67108864) // 64 MB, 8M offsets
64 #define FDB_COMP_BUF_MAXSIZE (1073741824) // 1 GB, 128M offsets
65 // Minimum window size for compaction sorting window, 128K offsets.
66 #define FDB_COMP_WINDOW_MINSIZE (131072)
67 #define FDB_COMP_BATCHSIZE (131072) // 128K docs
68 // Minimum batch size for compaction, 1024 docs.
69 #define FDB_COMP_BATCHSIZE_MIN (1024)
70 #define FDB_COMP_MOVE_UNIT (134217728) // 128 MB
71 #define FDB_COMP_RATIO_MIN (40) // 40% (writer speed / compactor speed)
72 #define FDB_COMP_RATIO_MAX (60) // 60% (writer speed / compactor speed)
73 #define FDB_COMP_PROB_UNIT_INC (5) // 5% (probability delta unit for increase)
74 #define FDB_COMP_PROB_UNIT_DEC (5) // 5% (probability delta unit for decrease)
75 
76 // full compaction internval in secs when the circular block reusing is enabled
77 #define FDB_COMPACTOR_SLEEP_DURATION (28800)
78 #define FDB_DEFAULT_COMPACTION_THRESHOLD (30)
79 
80 #define FDB_BGFLUSHER_SLEEP_DURATION (2)
81 #define FDB_BGFLUSHER_DIRTY_THRESHOLD (1024) //if more than this 4MB dirty
82                                              // wake up any sleeping bgflusher
83 
84 #define BCACHE_NBUCKET (4099) // a prime number
85 #define BCACHE_NDICBUCKET (4099) // a prime number
86 #define BCACHE_FLUSH_UNIT (1048576) // 1MB
87 #define BCACHE_EVICT_UNIT (1)
88 #define BCACHE_MEMORY_THRESHOLD (0.8) // 80% of physical RAM
89 #define __BCACHE_SECOND_CHANCE
90 
91 #define FILEMGR_PREFETCH_UNIT (4194304) // 4MB
92 #define FILEMGR_RESIDENT_THRESHOLD (0.9) // 90 % of file is in buffer cache
93 #define __FILEMGR_DATA_PARTIAL_LOCK
94 //#define __FILEMGR_DATA_MUTEX_LOCK
95 
96 #define SB_DEFAULT_NUM_SUPERBLOCKS (4) // 4 superblocks for crash recovery
97 #define SB_MAX_BITMAP_DOC_SIZE (1048576) // 1MB, 4M bitmaps per doc
98 // Minimum file size for the condition that block reusing is triggered
99 #define SB_MIN_BLOCK_REUSING_FILESIZE (16777216) // 16MB
100 // Period that superblock is written into the file
101 #define SB_SYNC_PERIOD (4194304) // sync for every 4MB update
102 // Time limit for reusable block reclaim
103 #define SB_RECLAIM_TIMELIMIT (100000) // 100 ms
104 // Threshold for pre-reclaiming
105 #define SB_PRE_RECLAIM_RATIO (10) // 10 %
106 
107 #define __BTREEBLK_BLOCKPOOL
108 #define __BTREEBLK_SUBBLOCK
109 //#define __BTREEBLK_READ_TREE // not used now, for future use
110 #define BTREEBLK_AGE_LIMIT (10)
111 #define BTREEBLK_MIN_SUBBLOCK (128)
112 //#define __BTREEBLK_CACHE
113 #ifdef __BTREEBLK_CACHE
114     #define BTREEBLK_CACHE_LIMIT (8)
115 #endif
116 
117 //#define __UTREE
118 #ifdef __UTREE
119     #define __UTREE_HEADER_SIZE (16)
120     #undef BTREE_CRC_OFFSET
121     #define BTREE_CRC_OFFSET (__UTREE_HEADER_SIZE+8)
122 #endif
123 
124 // WAL parition sizes
125 #define DEFAULT_NUM_WAL_PARTITIONS (11) // a prime number
126 #define MAX_NUM_WAL_PARTITIONS (512)
127 
128 // Buffer cache partition size
129 #define DEFAULT_NUM_BCACHE_PARTITIONS (11) // a prime number
130 #define MAX_NUM_BCACHE_PARTITIONS (512)
131 
132 // Asynchronous I/O queue depth
133 #define ASYNC_IO_QUEUE_DEPTH (64)
134 
135 // Number of daemon compactor threads
136 #define DEFAULT_NUM_COMPACTOR_THREADS (4)
137 #define MAX_NUM_COMPACTOR_THREADS (128)
138 
139 #define DEFAULT_NUM_BGFLUSHER_THREADS (2)
140 #define MAX_NUM_BGFLUSHER_THREADS (64)
141 #endif
142