Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-ds-badger
Commits
b608e4fb
Unverified
Commit
b608e4fb
authored
Mar 27, 2020
by
Steven Allen
Committed by
GitHub
Mar 27, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #83 from ipfs/feat/fileio
feat: switch to file io and shrink tables
parents
8f15d7da
818d0d78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
datastore.go
datastore.go
+22
-1
No files found.
datastore.go
View file @
b608e4fb
...
...
@@ -8,6 +8,7 @@ import (
"time"
badger
"github.com/dgraph-io/badger"
options
"github.com/dgraph-io/badger/options"
ds
"github.com/ipfs/go-datastore"
dsq
"github.com/ipfs/go-datastore/query"
logger
"github.com/ipfs/go-log"
...
...
@@ -71,10 +72,30 @@ func init() {
GcDiscardRatio
:
0.2
,
GcInterval
:
15
*
time
.
Minute
,
GcSleep
:
10
*
time
.
Second
,
Options
:
badger
.
Default
Options
(
""
),
Options
:
badger
.
LSMOnly
Options
(
""
),
}
// This is to optimize the database on close so it can be opened
// read-only and efficiently queried. We don't do that and hanging on
// stop isn't nice.
DefaultOptions
.
Options
.
CompactL0OnClose
=
false
// The alternative is "crash on start and tell the user to fix it". This
// will truncate corrupt and unsynced data, which we don't guarantee to
// persist anyways.
DefaultOptions
.
Options
.
Truncate
=
true
// Uses less memory, is no slower when writing, and is faster when
// reading (in some tests).
DefaultOptions
.
Options
.
ValueLogLoadingMode
=
options
.
FileIO
// Explicitly set this to mmap. This doesn't use much memory anyways.
DefaultOptions
.
Options
.
TableLoadingMode
=
options
.
MemoryMap
// Reduce this from 64MiB to 16MiB. That means badger will hold on to
// 20MiB by default instead of 80MiB.
//
// This does not appear to have a significant performance hit.
DefaultOptions
.
Options
.
MaxTableSize
=
16
<<
20
}
var
_
ds
.
Datastore
=
(
*
Datastore
)(
nil
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment