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

chore(dgraph): changing allocators to work with tags #7516

Merged
merged 5 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func RemoveRange(bm *roaring64.Bitmap, from, to uint64) {
// DecodeToBuffer is the same as Decode but it returns a z.Buffer which is
// calloc'ed and can be SHOULD be freed up by calling buffer.Release().
func DecodeToBuffer(bm *roaring64.Bitmap) *z.Buffer {
buf, err := z.NewBufferWith(256<<20, 32<<30, z.UseCalloc)
buf, err := z.NewBufferWith(256<<20, 32<<30, z.UseCalloc, "Codec.DecodeToBuffer")
x.Check(err)
buf.AutoMmapAfter(1 << 30)

Expand Down
4 changes: 2 additions & 2 deletions dgraph/cmd/bulk/count_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ func (c *countIndexer) writeIndex(buf *z.Buffer) {
fmt.Printf("Writing count index for %q rev=%v\n", pk.Attr, pk.IsReverse())
}

alloc := z.NewAllocator(8 << 20)
alloc := z.NewAllocator(8<<20, "CountIndexer.WriteIndex")
defer alloc.Release()

var pl pb.PostingList
bm := roaring64.New()

outBuf := z.NewBuffer(5 << 20)
outBuf := z.NewBuffer(5<<20, "CountIndexer.Buffer.WriteIndex")
defer outBuf.Release()
encode := func() {
if bm.GetCardinality() == 0 {
Expand Down
2 changes: 1 addition & 1 deletion dgraph/cmd/bulk/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type shardState struct {
func newMapperBuffer(opt *options) *z.Buffer {
sz := float64(opt.MapBufSize) * 1.1
buf, err := z.NewBufferWithDir(int(sz), 2*int(opt.MapBufSize), z.UseMmap,
filepath.Join(opt.TmpDir, bufferDir))
filepath.Join(opt.TmpDir, bufferDir), "Mapper.Buffer")
x.Check(err)
return buf
}
Expand Down
9 changes: 5 additions & 4 deletions dgraph/cmd/bulk/reduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (r *reducer) startWriting(ci *countIndexer, writerCh chan *encodeRequest, c
StreamDone: true,
}

buf := z.NewBuffer(512)
buf := z.NewBuffer(512, "Reducer.Write")
defer buf.Release()
badger.KVToBuffer(doneKV, buf)

Expand Down Expand Up @@ -437,7 +437,8 @@ func bufferStats(cbuf *z.Buffer) {
}

func getBuf(dir string) *z.Buffer {
cbuf, err := z.NewBufferWithDir(64<<20, 64<<30, z.UseCalloc, filepath.Join(dir, bufferDir))
cbuf, err := z.NewBufferWithDir(64<<20, 64<<30, z.UseCalloc,
filepath.Join(dir, bufferDir), "Reducer.GetBuf")
x.Check(err)
cbuf.AutoMmapAfter(1 << 30)
return cbuf
Expand Down Expand Up @@ -550,7 +551,7 @@ func (r *reducer) toList(req *encodeRequest) {
pl := new(pb.PostingList)
writeVersionTs := r.state.writeTs

kvBuf := z.NewBuffer(260 << 20)
kvBuf := z.NewBuffer(260<<20, "Reducer.Buffer.ToList")
trackCountIndex := make(map[string]bool)

var freePostings []*pb.Posting
Expand Down Expand Up @@ -691,7 +692,7 @@ func (r *reducer) toList(req *encodeRequest) {

if kvBuf.LenNoPadding() > 256<<20 {
req.listCh <- kvBuf
kvBuf = z.NewBuffer(260 << 20)
kvBuf = z.NewBuffer(260<<20, "Reducer.Buffer.KVBuffer")
}
}
end = next
Expand Down
2 changes: 1 addition & 1 deletion dgraph/cmd/debug/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func rollupKey(db *badger.DB) {
pl, err := posting.ReadPostingList(item.KeyCopy(nil), itr)
x.Check(err)

alloc := z.NewAllocator(32 << 20)
alloc := z.NewAllocator(32<<20, "Debug.RollupKey")
defer alloc.Release()

kvs, err := pl.Rollup(alloc)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ require (
github.com/Shopify/sarama v1.27.2
github.com/blevesearch/bleve v1.0.13
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd
github.com/dgraph-io/badger/v3 v3.0.0-20210303071538-42d5e9510a4d
github.com/dgraph-io/badger/v3 v3.0.0-20210303185901-6121fdc57546
github.com/dgraph-io/dgo/v200 v200.0.0-20210212152539-e0a5bde40ba2
github.com/dgraph-io/gqlgen v0.13.2
github.com/dgraph-io/gqlparser/v2 v2.1.8
github.com/dgraph-io/graphql-transport-ws v0.0.0-20210223074046-e5b8b80bb4ed
github.com/dgraph-io/ristretto v0.0.4-0.20210223002318-8ec1dc18f880
github.com/dgraph-io/ristretto v0.0.4-0.20210303184538-12d7dcf7c838
github.com/dgraph-io/roaring v0.5.6-0.20210227175938-766b897233a5
github.com/dgraph-io/simdjson-go v0.3.0
github.com/dgrijalva/jwt-go v3.2.0+incompatible
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ github.com/dgraph-io/badger v1.6.0 h1:DshxFxZWXUcO0xX476VJC07Xsr6ZCBVRHKZ93Oh7Ev
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
github.com/dgraph-io/badger/v3 v3.0.0-20210303071538-42d5e9510a4d h1:6ykqhVkgHypRkqIU95iFL3Ir+sY4bt9+gkElBu7PPQ0=
github.com/dgraph-io/badger/v3 v3.0.0-20210303071538-42d5e9510a4d/go.mod h1:m0D1mIoSHk/Ph/5nUU1Ft3raZHHQ3M7VBs5Iu1qbdHw=
github.com/dgraph-io/badger/v3 v3.0.0-20210303185901-6121fdc57546 h1:MpsltqvTNzssvU1j9TX4pxTOeGEpxE2BDNbEzrJBE6I=
aman-bansal marked this conversation as resolved.
Show resolved Hide resolved
github.com/dgraph-io/badger/v3 v3.0.0-20210303185901-6121fdc57546/go.mod h1:RN2qv9bN6jMtj+yZG0SvS1E25+NQ2cPTGiMgn0glnEA=
github.com/dgraph-io/dgo/v200 v200.0.0-20210212152539-e0a5bde40ba2 h1:3STgJCaLdsBynA0FDLqocwk/OdlnrQ5MGbR74C4NvUs=
github.com/dgraph-io/dgo/v200 v200.0.0-20210212152539-e0a5bde40ba2/go.mod h1:zCfS4R3E/UC/PhETXJYq/Blia0eCH1EQqKrWDvvimxE=
github.com/dgraph-io/gqlgen v0.13.2 h1:TNhndk+eHKj5qE7BenKKSYdSIdOGhLqxR1rCiMso9KM=
Expand All @@ -137,6 +139,8 @@ github.com/dgraph-io/ristretto v0.0.4-0.20210205182321-f8e4908e34d1 h1:E+NH1+aTO
github.com/dgraph-io/ristretto v0.0.4-0.20210205182321-f8e4908e34d1/go.mod h1:tv2ec8nA7vRpSYX7/MbP52ihrUMXIHit54CQMq8npXQ=
github.com/dgraph-io/ristretto v0.0.4-0.20210223002318-8ec1dc18f880 h1:O/ele7cFBjTncG2sFb2D4BbL5vYk577hSsG6dmBs9AM=
github.com/dgraph-io/ristretto v0.0.4-0.20210223002318-8ec1dc18f880/go.mod h1:MIonLggsKgZLUSt414ExgwNtlOL5MuEoAJP514mwGe8=
github.com/dgraph-io/ristretto v0.0.4-0.20210303184538-12d7dcf7c838 h1:ShF3qLqrZEhsPtlWSIry3w35SBQA5/W1STDSp/b0nvk=
github.com/dgraph-io/ristretto v0.0.4-0.20210303184538-12d7dcf7c838/go.mod h1:MIonLggsKgZLUSt414ExgwNtlOL5MuEoAJP514mwGe8=
github.com/dgraph-io/roaring v0.5.6-0.20210227175938-766b897233a5 h1:9t3OKcvsQlxU9Cu0U55tgvNtaRYVGDr6rUb95P8cSbg=
github.com/dgraph-io/roaring v0.5.6-0.20210227175938-766b897233a5/go.mod h1:I8kxPBtSQW3OdQFWonumQdCx2DTmq2WjdnTjGXz3uTM=
github.com/dgraph-io/simdjson-go v0.3.0 h1:h71LO7vR4LHMPUhuoGN8bqGm1VNfGOlAG8BI6iDUKw0=
Expand Down
2 changes: 1 addition & 1 deletion query/outputnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func newEncoder() *encoder {
attrMap: make(map[string]uint16),
idSlice: idSlice,
arena: a,
alloc: z.NewAllocator(4 << 10),
alloc: z.NewAllocator(4<<10, "OutputNode.Encoder"),
buf: &bytes.Buffer{},
}
e.uidAttr = e.idForAttr("uid")
Expand Down
2 changes: 1 addition & 1 deletion worker/backup_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (pr *BackupProcessor) WriteBackup(ctx context.Context) (*pb.BackupResponse,
// This is used to backup the schema and types.
writePrefix := func(prefix byte) error {
tl := threadLocal{
alloc: z.NewAllocator(1 << 10),
alloc: z.NewAllocator(1<<10, "BackupProcessor.WritePrefix"),
}
defer tl.alloc.Release()

Expand Down
2 changes: 1 addition & 1 deletion worker/predicate_move.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func movePredicateHelper(ctx context.Context, in *pb.MovePredicatePayload) error
if err != nil {
return err
}
buf := z.NewBuffer(1024)
buf := z.NewBuffer(1024, "PredicateMove.MovePredicateHelper")
defer buf.Release()

kv := &bpb.KV{}
Expand Down
2 changes: 1 addition & 1 deletion x/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func BuildDetails() string {
"Community License"
}

buf := z.CallocNoRef(1)
buf := z.CallocNoRef(1, "X.BuildDetails")
jem := len(buf) > 0
z.Free(buf)

Expand Down
2 changes: 1 addition & 1 deletion xidmap/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Trie struct {
// NewTrie would return back a Trie backed by the provided Arena. Trie would assume ownership of the
// Arena. Release must be called at the end to release Arena's resources.
func NewTrie() *Trie {
buf, err := z.NewBufferWith(32<<20, math.MaxUint32, z.UseMmap)
buf, err := z.NewBufferWith(32<<20, math.MaxUint32, z.UseMmap, "Trie")
x.Check(err)
// Add additional 8 bytes at the start, because offset=0 is used for checking non-existing node.
// Therefore we can't keep root at 0 offset.
Expand Down