forked from dgraph-io/badger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
112 lines (96 loc) · 3.66 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package badger
import (
"github.com/dgraph-io/badger/options"
)
// NOTE: Keep the comments in the following to 75 chars width, so they
// format nicely in godoc.
// Options are params for creating DB object.
//
// This package provides DefaultOptions which contains options that should
// work for most applications. Consider using that as a starting point before
// customizing it for your own needs.
type Options struct {
// 1. Mandatory flags
// -------------------
// Directory to store the data in. Should exist and be writable.
Dir string
// Directory to store the value log in. Can be the same as Dir. Should
// exist and be writable.
ValueDir string
// 2. Frequently modified flags
// -----------------------------
// Sync all writes to disk. Setting this to true would slow down data
// loading significantly.
SyncWrites bool
// How should LSM tree be accessed.
TableLoadingMode options.FileLoadingMode
// How should value log be accessed
ValueLogLoadingMode options.FileLoadingMode
// 3. Flags that user might want to review
// ----------------------------------------
// The following affect all levels of LSM tree.
MaxTableSize int64 // Each table (or file) is at most this size.
LevelSizeMultiplier int // Equals SizeOf(Li+1)/SizeOf(Li).
MaxLevels int // Maximum number of levels of compaction.
// If value size >= this threshold, only store value offsets in tree.
ValueThreshold int
// Maximum number of tables to keep in memory, before stalling.
NumMemtables int
// The following affect how we handle LSM tree L0.
// Maximum number of Level 0 tables before we start compacting.
NumLevelZeroTables int
// If we hit this number of Level 0 tables, we will stall until L0 is
// compacted away.
NumLevelZeroTablesStall int
// Maximum total size for L1.
LevelOneSize int64
// Size of single value log file.
ValueLogFileSize int64
// Number of compaction workers to run concurrently.
NumCompactors int
// Transaction start and commit timestamps are manaVgedTxns by end-user. This
// is a private option used by ManagedDB.
managedTxns bool
// 4. Flags for testing purposes
// ------------------------------
DoNotCompact bool // Stops LSM tree from compactions.
maxBatchCount int64 // max entries in batch
maxBatchSize int64 // max batch size in bytes
}
// DefaultOptions sets a list of recommended options for good performance.
// Feel free to modify these to suit your needs.
var DefaultOptions = Options{
DoNotCompact: false,
LevelOneSize: 256 << 20,
LevelSizeMultiplier: 10,
TableLoadingMode: options.LoadToRAM,
ValueLogLoadingMode: options.MemoryMap,
// table.MemoryMap to mmap() the tables.
// table.Nothing to not preload the tables.
MaxLevels: 7,
MaxTableSize: 64 << 20,
NumCompactors: 3,
NumLevelZeroTables: 5,
NumLevelZeroTablesStall: 10,
NumMemtables: 5,
SyncWrites: true,
// Nothing to read/write value log using standard File I/O
// MemoryMap to mmap() the value log files
ValueLogFileSize: 1 << 30,
ValueThreshold: 20,
}