go-ipfs-config: Add badger2 profile and config spec
gammazero committed
Sep 24, 2020 at 05:21 UTC
1ec9262cdaac5547b88bb6b5f600a75a327f5456
2 files changed
+36
-2
config/init.go
+13
@@ -142,6 +142,19 @@ func badgerSpec() map[string]interface{} {
142
}
143
}
144
145
+func badger2Spec() map[string]interface{} {
146
+ return map[string]interface{}{
147
+ "type": "measure",
148
+ "prefix": "badger2.datastore",
149
+ "child": map[string]interface{}{
150
+ "type": "badger2ds",
151
+ "path": "badger2ds",
152
+ "syncWrites": false,
153
+ "truncate": true,
154
+ },
155
+ }
156
+}
157
+
158
func flatfsSpec() map[string]interface{} {
159
return map[string]interface{}{
160
"type": "mount",
config/profile.go
+23
-2
@@ -130,7 +130,7 @@ This profile may only be applied when first initializing the node.
130
This is the most battle-tested and reliable datastore, but it's significantly
131
slower than the badger datastore. You should use this datastore if:
132
133
-* You need a very simple and very reliable datastore you and trust your
133
+* You need a very simple and very reliable datastore and you trust your
134
filesystem. This datastore stores each block as a separate file in the
135
underlying filesystem so it's unlikely to loose data unless there's an issue
136
with the underlying file system.
@@ -152,7 +152,7 @@ This profile may only be applied when first initializing the node.
152
"badgerds": {
153
Description: `Configures the node to use the badger datastore.
154
155
-This is the fastest datastore. Use this datastore if performance, especially
155
+This is a fast datastore. Use this datastore if performance, especially
156
when adding many gigabytes of files, is critical. However:
157
158
* This datastore will not properly reclaim space when your datastore is
@@ -170,6 +170,27 @@ This profile may only be applied when first initializing the node.`,
170
return nil
171
},
172
},
173
+ "badger2ds": {
174
+ Description: `Configures the node to use the badger2 datastore.
175
+
176
+This is the fastest datastore. Use this datastore if performance, especially
177
+when adding many gigabytes of files, is critical. However:
178
+
179
+* This datastore will not properly reclaim space when your datastore is
180
+ smaller than several gigabytes. If you run IPFS with '--enable-gc' (you have
181
+ enabled block-level garbage collection), you plan on storing very little data in
182
+ your IPFS node, and disk usage is more critical than performance, consider using
183
+ flatfs.
184
+* This datastore uses up to several gigabytes of memory.
185
+
186
+This profile may only be applied when first initializing the node.`,
187
+
188
+ InitOnly: true,
189
+ Transform: func(c *Config) error {
190
+ c.Datastore.Spec = badger2Spec()
191
+ return nil
192
+ },
193
+ },
194
"lowpower": {
195
Description: `Reduces daemon overhead on the system. May affect node
196
functionality - performance of content discovery and data