Skip to content

Commit c27c7e9

Browse files
committed
Add a section about memory usage
1 parent 5410a46 commit c27c7e9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ version.
3535
- [Key-only iteration](#key-only-iteration)
3636
+ [Garbage Collection](#garbage-collection)
3737
+ [Database backup](#database-backup)
38+
+ [Memory usage](#memory-usage)
3839
+ [Statistics](#statistics)
3940
* [Resources](#resources)
4041
+ [Blog Posts](#blog-posts)
@@ -375,6 +376,21 @@ command above to upgrade your database to work with the latest version.
375376
badger_backup --dir <path/to/badgerdb> --backup-file badger.bak
376377
```
377378

379+
### Memory usage
380+
381+
Badger's memory usage is a function of:
382+
383+
- Number of memtables `(Options::NumMemtables)`
384+
- If you modify `NumMemtables`, also adjust `NumLevelZeroTables` and
385+
`NumLevelZeroTablesStall` accordingly.
386+
- Number of concurrent compactions `(Options::NumCompactors)`
387+
- Mode in which LSM tree is loaded `(Options::TableLoadingMode)`
388+
- Size of table `(Options::MaxTableSize)`
389+
- Size of value log file `(Options::ValueLogFileSize)`
390+
391+
If you want to decrease the memory usage of Badger instance, tweak these
392+
options ideally doing them one at a time until you achieve the desired
393+
memory usage.
378394

379395
### Statistics
380396
Badger records metrics using the [expvar] package, which is included in the Go

0 commit comments

Comments
 (0)