Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

adjust compression to optimize for speed

Chris Lua32abda1a3fb
diff --git a/weed/operation/compress.go b/weed/operation/compress.go
index a28fb33eca..7190eeeb25 100644
--- a/weed/operation/compress.go
+++ b/weed/operation/compress.go
@@ -72,7 +72,7 @@ func IsGzippableFileType(ext, mtype string) (shouldBeZipped, iAmSure bool) {
func GzipData(input []byte) ([]byte, error) {
buf := new(bytes.Buffer)
- w, _ := gzip.NewWriterLevel(buf, flate.BestCompression)
+ w, _ := gzip.NewWriterLevel(buf, flate.BestSpeed)
if _, err := w.Write(input); err != nil {
glog.V(2).Infoln("error compressing data:", err)
return nil, err
diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go
index 6bd2998265..dcab1a0ae5 100644
--- a/weed/operation/upload_content.go
+++ b/weed/operation/upload_content.go
@@ -2,6 +2,7 @@ package operation
import (
"bytes"
+ "compress/flate"
"compress/gzip"
"encoding/json"
"errors"
@@ -50,7 +51,7 @@ func Upload(uploadUrl string, filename string, reader io.Reader, isGzipped bool,
}
return upload_content(uploadUrl, func(w io.Writer) (err error) {
if shouldGzipNow {
- gzWriter := gzip.NewWriter(w)
+ gzWriter, _ := gzip.NewWriterLevel(w, flate.BestSpeed)
_, err = io.Copy(gzWriter, reader)
gzWriter.Close()
} else {