# Slow compaction progress and high memory usage

**URL:** <https://discuss.dgraph.io/t/slow-compaction-progress-and-high-memory-usage/8740>\
**Category:** Issues\
**Tags:** badger, kind:enhancement, status:accepted, priority:p1\
**Created:** [June 15, 2020, 11:28am UTC](https://discuss.dgraph.io/t/slow-compaction-progress-and-high-memory-usage/8740 "2020-06-15T11:28:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [June 15, 2020, 11:28am UTC](https://discuss.dgraph.io/t/slow-compaction-progress-and-high-memory-usage/8740/1 "2020-06-15T11:28:52Z")

</div>

**Moved from GitHub [badger/1370](https://github.com/dgraph-io/badger/issues/1370)**

_Posted by_ [jarifibrahim](https://github.com/jarifibrahim):

### What version of Badger are you using?

[https://github.com/dgraph-io/badger/commit/c45d966681d4a058df1190b10f1b5f60c9ab0b6d](https://github.com/dgraph-io/badger/commit/c45d966681d4a058df1190b10f1b5f60c9ab0b6d)

### Steps to Reproduce the issue

Run `badger benchmark write -m 1000` command.

### What did you see instead?

The compactions don’t seem to make progress very slow and L0 gets accumulated with data

```auto
badger 2020/06/15 16:45:07 INFO: Got compaction priority: {level:0 score:48.4 dropPrefix:[]}
badger 2020/06/15 16:45:07 INFO: Running for level: 0
badger 2020/06/15 16:45:07 INFO: Got compaction priority: {level:1 score:60.551320023834705 dropPrefix:[]}

badger 2020/06/15 16:27:51 INFO: Got compaction priority: {level:1 score:60.551320023834705 dropPrefix:[]}
Time elapsed: 01s, bytes written: 67 MB, speed: 67 MB/sec, entries written: 419420, speed: 419420/sec
badger 2020/06/15 16:27:52 INFO: Got compaction priority: {level:1 score:60.551320023834705 dropPrefix:[]}
Time elapsed: 02s, bytes written: 101 MB, speed: 50 MB/sec, entries written: 629130, speed: 314565/sec
badger 2020/06/15 16:27:53 INFO: Got compaction priority: {level:1 score:60.551320023834705 dropPrefix:[]}
Time elapsed: 03s, bytes written: 155 MB, speed: 52 MB/sec, entries written: 970782, speed: 323594/sec
badger 2020/06/15 16:27:54 INFO: Got compaction priority: {level:1 score:60.551320023834705 dropPrefix:[]}

```

A score of 1 means we’ve filled the level to 100% capacity. The problem here is that because of commit [Improve write stalling on level 0 and 1 · dgraph-io/badger@3747be5 · GitHub](https://github.com/dgraph-io/badger/commit/3747be59ebbbf34382ab8d84207151c7f7014da2) the writes do not get stalled and levels get filled up. My badger directory has 200+ level 0 tables and they were being compacted with the entire L1 (which has 300+ tables).
