Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions posting/size.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/hypermodeinc/dgraph/v25/protos/pb"
)

const sizeOfBucket = 14
const sizeOfBucket = 144

func (l *List) ApproximateSize() uint64 {
if l == nil {
Expand All @@ -29,14 +29,19 @@ func (l *List) ApproximateSize() uint64 {
1*8 + // mutation map pointer consists of 1 word.
2*8 + // minTs and maxTs take 1 word each.
3*8 + // array take 3 words. so key array is 3 words.
3*8 + // array take 3 words. so cache array is 3 words.
1*8 // So far 11 words, in order to round the slab we're adding one more word.
// so far basic struct layout has been calculated.

// Add each entry size of key array.
size += uint64(cap(l.key))
// add byte array memory
size += uint64(cap(l.key)) + uint64(cap(l.cache))

size += approxPostingListSize(l.plist)

if l.mutationMap != nil {
size += l.mutationMap.ApproximateSize()
}

return size
}

Expand All @@ -58,7 +63,7 @@ func approxPostingListSize(list *pb.PostingList) uint64 {
size += uint64(cap(list.Postings)) * 8
for _, p := range list.Postings {
// add the size of each posting.
size += calculatePostingSize(p) * uint64(len(list.Postings))
size += calculatePostingSize(p) * uint64(cap(list.Postings))
break
}

Expand Down Expand Up @@ -88,12 +93,16 @@ func (m *MutableLayer) ApproximateSize() uint64 {

// Add each entry size of committedEntries.
size += uint64(len(m.committedEntries)) * 8
for _, v := range m.committedUids {
Comment thread
xqqp marked this conversation as resolved.
size += calculatePostingSize(v) * uint64(len(m.committedEntries))
break
}

// Add each entry size of currentEntries.
size += uint64(len(m.currentEntries.Postings)) * 8
size += approxPostingListSize(m.currentEntries)
size += approxPostingListSize(m.lastEntry)

// Add each entry size of calculatedUids.
size += uint64(len(m.calculatedUids)) * 8
size += uint64(len(m.currentUids)) * 8
size += uint64(cap(m.calculatedUids)) * 8

return size
}
Expand Down
2 changes: 1 addition & 1 deletion worker/server_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
ZeroLimitsDefaults = `uid-lease=0; refill-interval=30s; disable-admin-http=false;`
GraphQLDefaults = `introspection=true; debug=false; extensions=true; poll-interval=1s; ` +
`lambda-url=;`
CacheDefaults = `size-mb=1024; percentage=40,40,20; remove-on-update=false`
CacheDefaults = `size-mb=4096; percentage=40,40,20; remove-on-update=false`
FeatureFlagsDefaults = `normalize-compatibility-mode=; enable-detailed-metrics=false`
)

Expand Down
Loading