Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize memory usage of table.TableIndex #1335

Closed
jarifibrahim opened this issue May 20, 2020 · 0 comments
Closed

Optimize memory usage of table.TableIndex #1335

jarifibrahim opened this issue May 20, 2020 · 0 comments
Labels
area/performance Performance related issues. kind/enhancement Something could be better. status/accepted We accept to investigate or work on it.

Comments

@jarifibrahim
Copy link
Contributor

Badger keeps the index used by each table in memory

badger/table/table.go

Lines 94 to 102 in 62b7a10

type Table struct {
sync.Mutex
fd *os.File // Own fd.
tableSize int // Initialized in OpenTable, using fd.Stat().
bfLock sync.Mutex
blockIndex []*pb.BlockOffset
ref int32 // For file garbage collection. Atomic.

As the number of SST grows, the number of in-memory index blocks grows. The memory usage grows linearly with the number of tables. We should be cache the index blocks in ristretto.

This issue was also seen on dgraph-io/dgraph#5361 (comment)

// HEAP //
File: dgraph
Type: inuse_space
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 44487.54MB, 99.36% of 44774.33MB total
Dropped 234 nodes (cum <= 223.87MB)
Showing top 10 nodes out of 60
      flat  flat%   sum%        cum   cum%
20127.60MB 44.95% 44.95% 20127.60MB 44.95%  github.com/dgraph-io/ristretto/z.(*Bloom).Size
15454.99MB 34.52% 79.47% 23157.80MB 51.72%  github.com/dgraph-io/badger/v2/pb.(*TableIndex).Unmarshal
 7702.81MB 17.20% 96.67%  7702.81MB 17.20%  github.com/dgraph-io/badger/v2/pb.(*BlockOffset).Unmarshal
@jarifibrahim jarifibrahim added kind/enhancement Something could be better. area/performance Performance related issues. status/accepted We accept to investigate or work on it. labels May 20, 2020
jarifibrahim pushed a commit that referenced this issue Oct 2, 2020
Fixes #1335

Signed-off-by: Tiger <rbalajis25@gmail.com>
manishrjain pushed a commit to outcaste-io/outserv that referenced this issue Jul 6, 2022
Fixes dgraph-io/badger#1335

Signed-off-by: Tiger <rbalajis25@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/performance Performance related issues. kind/enhancement Something could be better. status/accepted We accept to investigate or work on it.
Development

No branches or pull requests

1 participant