Skip to content

Commit

Permalink
Revert "*,sstable: upgrade zstd to v1.5.6"
Browse files Browse the repository at this point in the history
This reverts commit 975fbcb.

The CockroachDB build process is unable to build zstd at v1.5.6 on Linux.
Resolving this issue is tracked in cockroachdb/cockroach#105568.
  • Loading branch information
jbowens committed Jun 26, 2023
1 parent f4e9d3c commit ee53ada
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/cockroachdb/pebble

require (
github.com/DataDog/zstd v1.5.6-0.20230622172052-ea68dcab66c0
github.com/DataDog/zstd v1.4.5
github.com/HdrHistogram/hdrhistogram-go v1.1.2
github.com/cespare/xxhash/v2 v2.2.0
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw=
github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w=
github.com/DataDog/zstd v1.5.6-0.20230622172052-ea68dcab66c0 h1:ye3LRgDs6Og7SKC1wBQH8oMaGczhCRpPpnU74l4rma8=
github.com/DataDog/zstd v1.5.6-0.20230622172052-ea68dcab66c0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/GoogleCloudPlatform/cloudsql-proxy v0.0.0-20190129172621-c8b1d7a94ddf/go.mod h1:aJ4qN3TfrelA6NZ6AXsXRfmEVaYin3EDbSPJrKS8OXo=
github.com/HdrHistogram/hdrhistogram-go v1.1.2 h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob0t8PQPMybUNFM=
github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
Expand Down
13 changes: 6 additions & 7 deletions sstable/compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,23 @@ func decompressedLen(blockType blockType, b []byte) (int, int, error) {
}
}

func decompressInto(blockType blockType, compressed []byte, buf []byte) error {
func decompressInto(blockType blockType, compressed []byte, buf []byte) ([]byte, error) {
var result []byte
var err error
switch blockType {
case snappyCompressionBlockType:
result, err = snappy.Decode(buf, compressed)
case zstdCompressionBlockType:
err = decodeZstd(buf, compressed)
result = buf
result, err = decodeZstd(buf, compressed)
}
if err != nil {
return base.MarkCorruptionError(err)
return nil, base.MarkCorruptionError(err)
}
if len(result) != 0 && (len(result) != len(buf) || &result[0] != &buf[0]) {
return base.CorruptionErrorf("pebble/table: decompressed into unexpected buffer: %p != %p",
return nil, base.CorruptionErrorf("pebble/table: decompressed into unexpected buffer: %p != %p",
errors.Safe(result), errors.Safe(buf))
}
return nil
return result, nil
}

// decompressBlock decompresses an SST block, with space allocated from a cache.
Expand All @@ -69,7 +68,7 @@ func decompressBlock(cache *cache.Cache, blockType blockType, b []byte) (*cache.
// Allocate sufficient space from the cache.
decoded := cache.Alloc(decodedLen)
decodedBuf := decoded.Buf()
if err := decompressInto(blockType, b, decodedBuf); err != nil {
if _, err := decompressInto(blockType, b, decodedBuf); err != nil {
cache.Free(decoded)
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions sstable/compression_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"github.com/DataDog/zstd"
)

// decodeZstd decompresses src with the Zstandard algorithm. The destination
// buffer must already be sufficiently sized, otherwise decodeZstd may error.
func decodeZstd(dst, src []byte) error {
_, err := zstd.DecompressInto(dst, src)
return err
// decodeZstd decompresses b with the Zstandard algorithm.
// It reuses the preallocated capacity of decodedBuf if it is sufficient.
// On success, it returns the decoded byte slice.
func decodeZstd(decodedBuf, b []byte) ([]byte, error) {
return zstd.Decompress(decodedBuf, b)
}

// encodeZstd compresses b with the Zstandard algorithm at default compression
Expand Down
10 changes: 5 additions & 5 deletions sstable/compression_nocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ package sstable

import "github.com/klauspost/compress/zstd"

// decodeZstd decompresses src with the Zstandard algorithm. The destination
// buffer must already be sufficiently sized, otherwise decodeZstd may error.
func decodeZstd(dst, src []byte) error {
// decodeZstd decompresses b with the Zstandard algorithm.
// It reuses the preallocated capacity of decodedBuf if it is sufficient.
// On success, it returns the decoded byte slice.
func decodeZstd(decodedBuf, b []byte) ([]byte, error) {
decoder, _ := zstd.NewReader(nil)
defer decoder.Close()
_, err := decoder.DecodeAll(src, dst[:0])
return err
return decoder.DecodeAll(b, decodedBuf[:0])
}

// encodeZstd compresses b with the Zstandard algorithm at default compression
Expand Down
5 changes: 2 additions & 3 deletions sstable/suffix_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,8 @@ func readBlockBuf(r *Reader, bh BlockHandle, buf []byte) ([]byte, []byte, error)
if cap(buf) < decompressedLen {
buf = make([]byte, decompressedLen)
}
dst := buf[:decompressedLen]
err = decompressInto(typ, raw[prefix:], dst)
return dst, buf, err
res, err := decompressInto(typ, raw[prefix:], buf[:decompressedLen])
return res, buf, err
}

// memReader is a thin wrapper around a []byte such that it can be passed to
Expand Down
Binary file modified sstable/testdata/h.zstd-compression.sst
Binary file not shown.

0 comments on commit ee53ada

Please sign in to comment.