diff options
| author | jakka <jakkadoujin@gmail.com> | 2025-04-12 20:13:42 +0300 |
|---|---|---|
| committer | jakka <jakkadoujin@gmail.com> | 2025-04-12 20:13:42 +0300 |
| commit | 97fb2613beaefb8f72f583d43fdd34561cadfe5e (patch) | |
| tree | d5e7782855e64d8809ff824d05b9a4819cf5384f /cmd/init.go | |
| parent | 4ab05592633ae75de5a39d16495f57eb6ea263a2 (diff) | |
continued writing
Diffstat (limited to 'cmd/init.go')
| -rw-r--r-- | cmd/init.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/cmd/init.go b/cmd/init.go index 2459315..63a87e6 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -8,7 +8,10 @@ import ( "path/filepath" "runtime" "strings" + "time" + badger "github.com/dgraph-io/badger/v4" + "github.com/dgraph-io/badger/v4/options" "github.com/urfave/cli/v2" ) @@ -75,3 +78,60 @@ func initArgs(cCtx *cli.Context) (context.Context, error) { return context.WithValue(ctx, "encoder", strings.ReplaceAll(strings.Split(string(encoder), " ")[1], "\n", "")), nil } + +func Options(path string) badger.Options { + return badger.Options{ + Dir: path, + ValueDir: path, + + MemTableSize: 64 << 20, + BaseTableSize: 2 << 20, + BaseLevelSize: 10 << 20, + TableSizeMultiplier: 2, + LevelSizeMultiplier: 10, + MaxLevels: 7, + NumGoroutines: 8, + MetricsEnabled: false, + + NumCompactors: 4, // Run at least 2 compactors. Zero-th compactor prioritizes L0. + NumLevelZeroTables: 5, + NumLevelZeroTablesStall: 15, + NumMemtables: 5, + BloomFalsePositive: 0.01, + BlockSize: 4 * 1024, + SyncWrites: false, + NumVersionsToKeep: 1, + CompactL0OnClose: true, + VerifyValueChecksum: false, + Compression: options.Snappy, + BlockCacheSize: 256 << 20, + IndexCacheSize: 0, + + // The following benchmarks were done on a 4 KB block size (default block size). The + // compression is ratio supposed to increase with increasing compression level but since the + // input for compression algorithm is small (4 KB), we don't get significant benefit at + // level 3. + // NOTE: The benchmarks are with DataDog ZSTD that requires CGO. Hence, no longer valid. + // no_compression-16 10 502848865 ns/op 165.46 MB/s - + // zstd_compression/level_1-16 7 739037966 ns/op 112.58 MB/s 2.93 + // zstd_compression/level_3-16 7 756950250 ns/op 109.91 MB/s 2.72 + // zstd_compression/level_15-16 1 11135686219 ns/op 7.47 MB/s 4.38 + // Benchmark code can be found in table/builder_test.go file + ZSTDCompressionLevel: 1, + + // (2^30 - 1)*2 when mmapping < 2^31 - 1, max int32. + // -1 so 2*ValueLogFileSize won't overflow on 32-bit systems. + ValueLogFileSize: 1<<30 - 1, + + ValueLogMaxEntries: 1000000, + + VLogPercentile: 0.0, + ValueThreshold: (1 << 20), + + Logger: nil, + EncryptionKey: []byte{}, + EncryptionKeyRotationDuration: 10 * 24 * time.Hour, // Default 10 days. + DetectConflicts: true, + NamespaceOffset: -1, + } +} |
