Skip to content

Commit aa529a9

Browse files
authored
chore: switch to pure-go zstd decoder for snapshot imports (#12857)
* Switch to pure-go zstd decoder for snapshot imports The benchmarking performed as part of #12852 shows that the pure-go implementation of zstd decoder is fast-enough for snapshot import. Switch to it motivated by the desire to reduce CGO dependencies across Lotus. Fixes #12852 * Update the pain-log.
1 parent 99dcb12 commit aa529a9

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
- refactor(eth): attach ToFilecoinMessage converter to EthCall method for improved package/module import structure. This change also exports the converter as a public method, enhancing usability for developers utilizing Lotus as a library. ([filecoin-project/lotus#12844](https://github.com/filecoin-project/lotus/pull/12844))
1313

14+
- chore: switch to pure-go zstd decoder for snapshot imports. ([filecoin-project/lotus#12857](https://github.com/filecoin-project/lotus/pull/12857))
15+
1416
# UNRELEASED v.1.32.0
1517

1618
See https://github.com/filecoin-project/lotus/blob/release/v1.32.0/CHANGELOG.md

cli/lotus/daemon.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
"runtime/pprof"
1616
"strings"
1717

18-
"github.com/DataDog/zstd"
1918
"github.com/cheggaaa/pb/v3"
2019
metricsprom "github.com/ipfs/go-metrics-prometheus"
20+
"github.com/klauspost/compress/zstd"
2121
"github.com/mitchellh/go-homedir"
2222
"github.com/multiformats/go-multiaddr"
2323
"github.com/urfave/cli/v2"
@@ -579,12 +579,11 @@ func ImportChain(ctx context.Context, r repo.Repo, fname string, snapshot bool)
579579
var ir io.Reader = br
580580

581581
if string(header[1:]) == "\xB5\x2F\xFD" { // zstd
582-
zr := zstd.NewReader(br)
583-
defer func() {
584-
if err := zr.Close(); err != nil {
585-
log.Errorw("closing zstd reader", "error", err)
586-
}
587-
}()
582+
zr, err := zstd.NewReader(br)
583+
if err != nil {
584+
return xerrors.Errorf("instantiating zstd reader: %w", err)
585+
}
586+
defer zr.Close()
588587
ir = zr
589588
}
590589

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi // pro
1515
require (
1616
contrib.go.opencensus.io/exporter/prometheus v0.4.2
1717
github.com/BurntSushi/toml v1.3.2
18-
github.com/DataDog/zstd v1.4.5
1918
github.com/GeertJohan/go.rice v1.0.3
2019
github.com/Gurpartap/async v0.0.0-20180927173644-4f7f499dd9ee
2120
github.com/Kubuxu/imtui v0.0.0-20210401140320-41663d68d0fa

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8
5050
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
5151
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
5252
github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
53-
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
54-
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
5553
github.com/GeertJohan/go.incremental v1.0.0 h1:7AH+pY1XUgQE4Y1HcXYaMqAI0m9yrFqo/jt0CW30vsg=
5654
github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0=
5755
github.com/GeertJohan/go.rice v1.0.3 h1:k5viR+xGtIhF61125vCE1cmJ5957RQGXG6dmbaWZSmI=

0 commit comments

Comments
 (0)