Skip to content

Commit

Permalink
perf(compression): Use gzip with BestSpeed in export and backup (#7643)
Browse files Browse the repository at this point in the history
The export and backup code were using BestCompression and Default
gzip compression levels respectively. We see a 4x speed improvement when
switching from BestCompression to BestSpeed compression level.

(cherry picked from commit 5676462)
  • Loading branch information
Ibrahim Jarif committed Apr 5, 2021
1 parent 32f1f58 commit 57a7a86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions worker/backup_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,12 @@ func (pr *BackupProcessor) WriteBackup(ctx context.Context) (*pb.BackupResponse,

newhandler, err := enc.GetWriter(x.WorkerConfig.EncryptionKey, handler)
if err != nil {
return &response, err
return &response, errors.Wrap(err, "failed to get encWriter")
}
gzWriter, err := gzip.NewWriterLevel(newhandler, gzip.BestSpeed)
if err != nil {
return &response, errors.Wrap(err, "failed to create new gzip writer")
}
gzWriter := gzip.NewWriter(newhandler)

stream := pr.DB.NewStreamAt(pr.Request.ReadTs)
stream.LogPrefix = "Dgraph.Backup"
Expand Down
2 changes: 1 addition & 1 deletion worker/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func (writer *fileWriter) open(fpath string) error {
if err != nil {
return err
}
writer.gw, err = gzip.NewWriterLevel(w, gzip.BestCompression)
writer.gw, err = gzip.NewWriterLevel(w, gzip.BestSpeed)
return err
}

Expand Down

0 comments on commit 57a7a86

Please sign in to comment.