mirror of
https://github.com/mudler/luet.git
synced 2025-09-05 17:20:29 +00:00
Use goreleaser to build and release (#244)
Instead of using gox on one side and an action to release, we can merge them together with goreleaser which will build for extra targets (arm, mips if needed in the future) and it also takes care of creating checksums, a source archive, and a changelog and creating a release with all the artifacts. All binaries should respect the old naming convention, so any scripts out there should still work. Signed-off-by: Itxaka <igarcia@suse.com>
This commit is contained in:
92
vendor/github.com/klauspost/compress/zstd/blockdec.go
generated
vendored
92
vendor/github.com/klauspost/compress/zstd/blockdec.go
generated
vendored
@@ -11,6 +11,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/klauspost/compress/huff0"
|
||||
"github.com/klauspost/compress/zstd/internal/xxhash"
|
||||
)
|
||||
|
||||
type blockType uint8
|
||||
@@ -74,20 +75,29 @@ type blockDec struct {
|
||||
|
||||
// Window size of the block.
|
||||
WindowSize uint64
|
||||
Type blockType
|
||||
RLESize uint32
|
||||
|
||||
history chan *history
|
||||
input chan struct{}
|
||||
result chan decodeOutput
|
||||
sequenceBuf []seq
|
||||
err error
|
||||
decWG sync.WaitGroup
|
||||
|
||||
// Frame to use for singlethreaded decoding.
|
||||
// Should not be used by the decoder itself since parent may be another frame.
|
||||
localFrame *frameDec
|
||||
|
||||
// Block is RLE, this is the size.
|
||||
RLESize uint32
|
||||
tmp [4]byte
|
||||
|
||||
Type blockType
|
||||
|
||||
// Is this the last block of a frame?
|
||||
Last bool
|
||||
|
||||
// Use less memory
|
||||
lowMem bool
|
||||
history chan *history
|
||||
input chan struct{}
|
||||
result chan decodeOutput
|
||||
sequenceBuf []seq
|
||||
tmp [4]byte
|
||||
err error
|
||||
lowMem bool
|
||||
}
|
||||
|
||||
func (b *blockDec) String() string {
|
||||
@@ -104,6 +114,7 @@ func newBlockDec(lowMem bool) *blockDec {
|
||||
input: make(chan struct{}, 1),
|
||||
history: make(chan *history, 1),
|
||||
}
|
||||
b.decWG.Add(1)
|
||||
go b.startDecoder()
|
||||
return &b
|
||||
}
|
||||
@@ -124,25 +135,37 @@ func (b *blockDec) reset(br byteBuffer, windowSize uint64) error {
|
||||
b.Type = blockType((bh >> 1) & 3)
|
||||
// find size.
|
||||
cSize := int(bh >> 3)
|
||||
maxSize := maxBlockSize
|
||||
switch b.Type {
|
||||
case blockTypeReserved:
|
||||
return ErrReservedBlockType
|
||||
case blockTypeRLE:
|
||||
b.RLESize = uint32(cSize)
|
||||
if b.lowMem {
|
||||
maxSize = cSize
|
||||
}
|
||||
cSize = 1
|
||||
case blockTypeCompressed:
|
||||
if debug {
|
||||
println("Data size on stream:", cSize)
|
||||
}
|
||||
b.RLESize = 0
|
||||
maxSize = maxCompressedBlockSize
|
||||
if windowSize < maxCompressedBlockSize && b.lowMem {
|
||||
maxSize = int(windowSize)
|
||||
}
|
||||
if cSize > maxCompressedBlockSize || uint64(cSize) > b.WindowSize {
|
||||
if debug {
|
||||
printf("compressed block too big: csize:%d block: %+v\n", uint64(cSize), b)
|
||||
}
|
||||
return ErrCompressedSizeTooBig
|
||||
}
|
||||
default:
|
||||
case blockTypeRaw:
|
||||
b.RLESize = 0
|
||||
// We do not need a destination for raw blocks.
|
||||
maxSize = -1
|
||||
default:
|
||||
panic("Invalid block type")
|
||||
}
|
||||
|
||||
// Read block data.
|
||||
@@ -153,14 +176,15 @@ func (b *blockDec) reset(br byteBuffer, windowSize uint64) error {
|
||||
b.dataStorage = make([]byte, 0, maxBlockSize)
|
||||
}
|
||||
}
|
||||
if cap(b.dst) <= maxBlockSize {
|
||||
b.dst = make([]byte, 0, maxBlockSize+1)
|
||||
if cap(b.dst) <= maxSize {
|
||||
b.dst = make([]byte, 0, maxSize+1)
|
||||
}
|
||||
var err error
|
||||
b.data, err = br.readBig(cSize, b.dataStorage)
|
||||
if err != nil {
|
||||
if debug {
|
||||
println("Reading block:", err)
|
||||
println("Reading block:", err, "(", cSize, ")", len(b.data))
|
||||
printf("%T", br)
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -181,11 +205,13 @@ func (b *blockDec) Close() {
|
||||
close(b.input)
|
||||
close(b.history)
|
||||
close(b.result)
|
||||
b.decWG.Wait()
|
||||
}
|
||||
|
||||
// decodeAsync will prepare decoding the block when it receives input.
|
||||
// This will separate output and history.
|
||||
func (b *blockDec) startDecoder() {
|
||||
defer b.decWG.Done()
|
||||
for range b.input {
|
||||
//println("blockDec: Got block input")
|
||||
switch b.Type {
|
||||
@@ -275,7 +301,7 @@ func (b *blockDec) decodeBuf(hist *history) error {
|
||||
hist.b = nil
|
||||
err := b.decodeCompressed(hist)
|
||||
if debug {
|
||||
println("Decompressed to total", len(b.dst), "bytes, error:", err)
|
||||
println("Decompressed to total", len(b.dst), "bytes, hash:", xxhash.Sum64(b.dst), "error:", err)
|
||||
}
|
||||
hist.b = b.dst
|
||||
b.dst = saved
|
||||
@@ -368,7 +394,7 @@ func (b *blockDec) decodeCompressed(hist *history) error {
|
||||
}
|
||||
}
|
||||
if debug {
|
||||
println("literals type:", litType, "litRegenSize:", litRegenSize, "litCompSize", litCompSize)
|
||||
println("literals type:", litType, "litRegenSize:", litRegenSize, "litCompSize:", litCompSize, "sizeFormat:", sizeFormat, "4X:", fourStreams)
|
||||
}
|
||||
var literals []byte
|
||||
var huff *huff0.Scratch
|
||||
@@ -426,7 +452,6 @@ func (b *blockDec) decodeCompressed(hist *history) error {
|
||||
}
|
||||
literals = in[:litCompSize]
|
||||
in = in[litCompSize:]
|
||||
|
||||
huff = huffDecoderPool.Get().(*huff0.Scratch)
|
||||
var err error
|
||||
// Ensure we have space to store it.
|
||||
@@ -440,26 +465,22 @@ func (b *blockDec) decodeCompressed(hist *history) error {
|
||||
if huff == nil {
|
||||
huff = &huff0.Scratch{}
|
||||
}
|
||||
huff.Out = b.literalBuf[:0]
|
||||
huff, literals, err = huff0.ReadTable(literals, huff)
|
||||
if err != nil {
|
||||
println("reading huffman table:", err)
|
||||
return err
|
||||
}
|
||||
// Use our out buffer.
|
||||
huff.Out = b.literalBuf[:0]
|
||||
huff.MaxDecodedSize = litRegenSize
|
||||
if fourStreams {
|
||||
literals, err = huff.Decompress4X(literals, litRegenSize)
|
||||
literals, err = huff.Decoder().Decompress4X(b.literalBuf[:0:litRegenSize], literals)
|
||||
} else {
|
||||
literals, err = huff.Decompress1X(literals)
|
||||
literals, err = huff.Decoder().Decompress1X(b.literalBuf[:0:litRegenSize], literals)
|
||||
}
|
||||
if err != nil {
|
||||
println("decoding compressed literals:", err)
|
||||
return err
|
||||
}
|
||||
// Make sure we don't leak our literals buffer
|
||||
huff.Out = nil
|
||||
if len(literals) != litRegenSize {
|
||||
return fmt.Errorf("literal output size mismatch want %d, got %d", litRegenSize, len(literals))
|
||||
}
|
||||
@@ -592,7 +613,7 @@ func (b *blockDec) decodeCompressed(hist *history) error {
|
||||
// Decode treeless literal block.
|
||||
if litType == literalsBlockTreeless {
|
||||
// TODO: We could send the history early WITHOUT the stream history.
|
||||
// This would allow decoding treeless literials before the byte history is available.
|
||||
// This would allow decoding treeless literals before the byte history is available.
|
||||
// Silencia stats: Treeless 4393, with: 32775, total: 37168, 11% treeless.
|
||||
// So not much obvious gain here.
|
||||
|
||||
@@ -610,15 +631,12 @@ func (b *blockDec) decodeCompressed(hist *history) error {
|
||||
var err error
|
||||
// Use our out buffer.
|
||||
huff = hist.huffTree
|
||||
huff.Out = b.literalBuf[:0]
|
||||
huff.MaxDecodedSize = litRegenSize
|
||||
if fourStreams {
|
||||
literals, err = huff.Decompress4X(literals, litRegenSize)
|
||||
literals, err = huff.Decoder().Decompress4X(b.literalBuf[:0:litRegenSize], literals)
|
||||
} else {
|
||||
literals, err = huff.Decompress1X(literals)
|
||||
literals, err = huff.Decoder().Decompress1X(b.literalBuf[:0:litRegenSize], literals)
|
||||
}
|
||||
// Make sure we don't leak our literals buffer
|
||||
huff.Out = nil
|
||||
if err != nil {
|
||||
println("decompressing literals:", err)
|
||||
return err
|
||||
@@ -628,16 +646,17 @@ func (b *blockDec) decodeCompressed(hist *history) error {
|
||||
}
|
||||
} else {
|
||||
if hist.huffTree != nil && huff != nil {
|
||||
huffDecoderPool.Put(hist.huffTree)
|
||||
if hist.dict == nil || hist.dict.litEnc != hist.huffTree {
|
||||
huffDecoderPool.Put(hist.huffTree)
|
||||
}
|
||||
hist.huffTree = nil
|
||||
}
|
||||
}
|
||||
if huff != nil {
|
||||
huff.Out = nil
|
||||
hist.huffTree = huff
|
||||
}
|
||||
if debug {
|
||||
println("Final literals:", len(literals), "and", nSeqs, "sequences.")
|
||||
println("Final literals:", len(literals), "hash:", xxhash.Sum64(literals), "and", nSeqs, "sequences.")
|
||||
}
|
||||
|
||||
if nSeqs == 0 {
|
||||
@@ -666,12 +685,21 @@ func (b *blockDec) decodeCompressed(hist *history) error {
|
||||
// If only recent offsets were not transferred, this would be an obvious win.
|
||||
// Also, if first 3 sequences don't reference recent offsets, all sequences can be decoded.
|
||||
|
||||
hbytes := hist.b
|
||||
if len(hbytes) > hist.windowSize {
|
||||
hbytes = hbytes[len(hbytes)-hist.windowSize:]
|
||||
// We do not need history any more.
|
||||
if hist.dict != nil {
|
||||
hist.dict.content = nil
|
||||
}
|
||||
}
|
||||
|
||||
if err := seqs.initialize(br, hist, literals, b.dst); err != nil {
|
||||
println("initializing sequences:", err)
|
||||
return err
|
||||
}
|
||||
|
||||
err = seqs.decode(nSeqs, br, hist.b)
|
||||
err = seqs.decode(nSeqs, br, hbytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user