Skip to content

Commit

Permalink
opt(snapshot): use full table copy when streaming the entire data (#7870
Browse files Browse the repository at this point in the history
)

When streaming the entire data in the snapshot (snap.SinceTs=0), we can do
an entire table copy instead of iterating over the KVs. This brings about
3x performance improvement, as well as the CPU of the sender, is idle.
Refer dgraph-io/badger#1700 for more details.
  • Loading branch information
NamanJain8 authored and mangalaman93 committed Mar 7, 2023
1 parent 129ae0e commit 011b406
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/Masterminds/semver/v3 v3.1.0
github.com/Shopify/sarama v1.27.2
github.com/blevesearch/bleve v1.0.13
github.com/dgraph-io/badger/v4 v4.0.2-0.20230307194143-24ef3aab9eda
github.com/dgraph-io/badger/v4 v4.0.2-0.20230307194918-e55f05f923e1
github.com/dgraph-io/dgo/v210 v210.0.0-20210407152819-261d1c2a6987
github.com/dgraph-io/gqlgen v0.13.2
github.com/dgraph-io/gqlparser/v2 v2.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
github.com/dgraph-io/badger/v4 v4.0.2-0.20230307194143-24ef3aab9eda h1:YtklLh8nmh/Y5TJPjJlcg3Ev1HMjasUAn4ty213CI4Y=
github.com/dgraph-io/badger/v4 v4.0.2-0.20230307194143-24ef3aab9eda/go.mod h1:Ghj1IjxpaEbozo6F4jV3QDYyah5uzYJWDcjZ82dBDdg=
github.com/dgraph-io/badger/v4 v4.0.2-0.20230307194918-e55f05f923e1 h1:0ApclJzjWzS//p8DHlNrOObn9M9g5HeD30qNgm7/BJg=
github.com/dgraph-io/badger/v4 v4.0.2-0.20230307194918-e55f05f923e1/go.mod h1:Ghj1IjxpaEbozo6F4jV3QDYyah5uzYJWDcjZ82dBDdg=
github.com/dgraph-io/dgo/v210 v210.0.0-20210407152819-261d1c2a6987 h1:5aN6H88a2q3HkO8vSZxDlgjEpJf4Fz8rfy+/Wzx2uAc=
github.com/dgraph-io/dgo/v210 v210.0.0-20210407152819-261d1c2a6987/go.mod h1:dCzdThGGTPYOAuNtrM6BiXj/86voHn7ZzkPL6noXR3s=
github.com/dgraph-io/gqlgen v0.13.2 h1:TNhndk+eHKj5qE7BenKKSYdSIdOGhLqxR1rCiMso9KM=
Expand Down
5 changes: 5 additions & 0 deletions worker/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ func doStreamSnapshot(snap *pb.Snapshot, out pb.Worker_StreamSnapshotServer) err
// Use the default implementation. We no longer try to generate a rolled up posting list here.
// Instead, we just stream out all the versions as they are.
stream.KeyToList = nil
stream.SinceTs = snap.SinceTs
if snap.SinceTs == 0 {
// Do full table copy when streaming the entire data.
stream.FullCopy = true
}
stream.Send = func(buf *z.Buffer) error {
kvs := &pb.KVS{Data: buf.Bytes()}
return out.Send(kvs)
Expand Down

0 comments on commit 011b406

Please sign in to comment.