MCPcopy
hub / github.com/dgraph-io/badger / DefaultOptions

Function DefaultOptions

options.go:120–175  ·  view source on GitHub ↗

DefaultOptions sets a list of recommended options for good performance. Feel free to modify these to suit your needs with the WithX methods.

(path string)

Source from the content-addressed store, hash-verified

118// DefaultOptions sets a list of recommended options for good performance.
119// Feel free to modify these to suit your needs with the WithX methods.
120func DefaultOptions(path string) Options {
121 return Options{
122 Dir: path,
123 ValueDir: path,
124 LevelOneSize: 256 << 20,
125 LevelSizeMultiplier: 10,
126 TableLoadingMode: options.MemoryMap,
127 ValueLogLoadingMode: options.MemoryMap,
128 // table.MemoryMap to mmap() the tables.
129 // table.Nothing to not preload the tables.
130 MaxLevels: 7,
131 MaxTableSize: 64 << 20,
132 NumCompactors: 2, // Compactions can be expensive. Only run 2.
133 NumLevelZeroTables: 5,
134 NumLevelZeroTablesStall: 10,
135 NumMemtables: 5,
136 BloomFalsePositive: 0.01,
137 BlockSize: 4 * 1024,
138 SyncWrites: true,
139 NumVersionsToKeep: 1,
140 CompactL0OnClose: true,
141 KeepL0InMemory: false,
142 VerifyValueChecksum: false,
143 Compression: options.None,
144 MaxCacheSize: 0,
145 MaxBfCacheSize: 0,
146 LoadBloomsOnOpen: true,
147 // The following benchmarks were done on a 4 KB block size (default block size). The
148 // compression is ratio supposed to increase with increasing compression level but since the
149 // input for compression algorithm is small (4 KB), we don't get significant benefit at
150 // level 3.
151 // no_compression-16 10 502848865 ns/op 165.46 MB/s -
152 // zstd_compression/level_1-16 7 739037966 ns/op 112.58 MB/s 2.93
153 // zstd_compression/level_3-16 7 756950250 ns/op 109.91 MB/s 2.72
154 // zstd_compression/level_15-16 1 11135686219 ns/op 7.47 MB/s 4.38
155 // Benchmark code can be found in table/builder_test.go file
156 ZSTDCompressionLevel: 1,
157
158 // Nothing to read/write value log using standard File I/O
159 // MemoryMap to mmap() the value log files
160 // (2^30 - 1)*2 when mmapping < 2^31 - 1, max int32.
161 // -1 so 2*ValueLogFileSize won't overflow on 32-bit systems.
162 ValueLogFileSize: 1<<30 - 1,
163
164 ValueLogMaxEntries: 1000000,
165 ValueThreshold: 1 << 10, // 1 KB.
166 Truncate: false,
167 Logger: defaultLogger(INFO),
168 LogRotatesToFlush: 2,
169 EncryptionKey: []byte{},
170 EncryptionKeyRotationDuration: 10 * 24 * time.Hour, // Default 10 days.
171 DetectConflicts: true,
172 KeepBlocksInCache: false,
173 KeepBlockIndicesInCache: false,
174 }
175}
176
177func buildTableOptions(opt Options) table.Options {

Callers 15

LSMOnlyOptionsFunction · 0.85
TestWriteBatchManagedFunction · 0.85
TestWriteBatchDuplicateFunction · 0.85
getTestOptionsFunction · 0.85
TestGetFunction · 0.85
TestExistsMoreFunction · 0.85
TestIterate2BasicFunction · 0.85
TestIterateParallelFunction · 0.85
TestLargeKeysFunction · 0.85

Calls 1

defaultLoggerFunction · 0.85

Tested by 15

TestWriteBatchManagedFunction · 0.68
TestWriteBatchDuplicateFunction · 0.68
getTestOptionsFunction · 0.68
TestGetFunction · 0.68
TestExistsMoreFunction · 0.68
TestIterate2BasicFunction · 0.68
TestIterateParallelFunction · 0.68
TestLargeKeysFunction · 0.68
TestCreateDirsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…