mirror of
https://github.com/mudler/luet.git
synced 2025-09-04 00:34:41 +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:
154
vendor/github.com/klauspost/compress/zstd/encoder_options.go
generated
vendored
154
vendor/github.com/klauspost/compress/zstd/encoder_options.go
generated
vendored
@@ -12,35 +12,56 @@ type EOption func(*encoderOptions) error
|
||||
|
||||
// options retains accumulated state of multiple options.
|
||||
type encoderOptions struct {
|
||||
concurrent int
|
||||
crc bool
|
||||
single *bool
|
||||
pad int
|
||||
blockSize int
|
||||
windowSize int
|
||||
level EncoderLevel
|
||||
fullZero bool
|
||||
concurrent int
|
||||
level EncoderLevel
|
||||
single *bool
|
||||
pad int
|
||||
blockSize int
|
||||
windowSize int
|
||||
crc bool
|
||||
fullZero bool
|
||||
noEntropy bool
|
||||
allLitEntropy bool
|
||||
customWindow bool
|
||||
customALEntropy bool
|
||||
lowMem bool
|
||||
dict *dict
|
||||
}
|
||||
|
||||
func (o *encoderOptions) setDefault() {
|
||||
*o = encoderOptions{
|
||||
// use less ram: true for now, but may change.
|
||||
concurrent: runtime.GOMAXPROCS(0),
|
||||
crc: true,
|
||||
single: nil,
|
||||
blockSize: 1 << 16,
|
||||
windowSize: 1 << 22,
|
||||
level: SpeedDefault,
|
||||
concurrent: runtime.GOMAXPROCS(0),
|
||||
crc: true,
|
||||
single: nil,
|
||||
blockSize: 1 << 16,
|
||||
windowSize: 8 << 20,
|
||||
level: SpeedDefault,
|
||||
allLitEntropy: true,
|
||||
lowMem: false,
|
||||
}
|
||||
}
|
||||
|
||||
// encoder returns an encoder with the selected options.
|
||||
func (o encoderOptions) encoder() encoder {
|
||||
switch o.level {
|
||||
case SpeedDefault:
|
||||
return &doubleFastEncoder{fastEncoder: fastEncoder{maxMatchOff: int32(o.windowSize)}}
|
||||
case SpeedFastest:
|
||||
return &fastEncoder{maxMatchOff: int32(o.windowSize)}
|
||||
if o.dict != nil {
|
||||
return &fastEncoderDict{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}}
|
||||
}
|
||||
return &fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}
|
||||
|
||||
case SpeedDefault:
|
||||
if o.dict != nil {
|
||||
return &doubleFastEncoderDict{fastEncoderDict: fastEncoderDict{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}}}
|
||||
}
|
||||
return &doubleFastEncoder{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}}
|
||||
case SpeedBetterCompression:
|
||||
if o.dict != nil {
|
||||
return &betterFastEncoderDict{betterFastEncoder: betterFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}}
|
||||
}
|
||||
return &betterFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}
|
||||
case SpeedBestCompression:
|
||||
return &bestFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}
|
||||
}
|
||||
panic("unknown compression level")
|
||||
}
|
||||
@@ -52,7 +73,7 @@ func WithEncoderCRC(b bool) EOption {
|
||||
}
|
||||
|
||||
// WithEncoderConcurrency will set the concurrency,
|
||||
// meaning the maximum number of decoders to run concurrently.
|
||||
// meaning the maximum number of encoders to run concurrently.
|
||||
// The value supplied must be at least 1.
|
||||
// By default this will be set to GOMAXPROCS.
|
||||
func WithEncoderConcurrency(n int) EOption {
|
||||
@@ -66,7 +87,7 @@ func WithEncoderConcurrency(n int) EOption {
|
||||
}
|
||||
|
||||
// WithWindowSize will set the maximum allowed back-reference distance.
|
||||
// The value must be a power of two between WindowSizeMin and WindowSizeMax.
|
||||
// The value must be a power of two between MinWindowSize and MaxWindowSize.
|
||||
// A larger value will enable better compression but allocate more memory and,
|
||||
// for above-default values, take considerably longer.
|
||||
// The default value is determined by the compression level.
|
||||
@@ -82,6 +103,7 @@ func WithWindowSize(n int) EOption {
|
||||
}
|
||||
|
||||
o.windowSize = n
|
||||
o.customWindow = true
|
||||
if o.blockSize > o.windowSize {
|
||||
o.blockSize = o.windowSize
|
||||
}
|
||||
@@ -129,25 +151,25 @@ const (
|
||||
// This is roughly equivalent to the default Zstandard mode (level 3).
|
||||
SpeedDefault
|
||||
|
||||
// SpeedBetterCompression will yield better compression than the default.
|
||||
// Currently it is about zstd level 7-8 with ~ 2x-3x the default CPU usage.
|
||||
// By using this, notice that CPU usage may go up in the future.
|
||||
SpeedBetterCompression
|
||||
|
||||
// SpeedBestCompression will choose the best available compression option.
|
||||
// This will offer the best compression no matter the CPU cost.
|
||||
SpeedBestCompression
|
||||
|
||||
// speedLast should be kept as the last actual compression option.
|
||||
// The is not for external usage, but is used to keep track of the valid options.
|
||||
speedLast
|
||||
|
||||
// SpeedBetterCompression will (in the future) yield better compression than the default,
|
||||
// but at approximately 4x the CPU usage of the default.
|
||||
// For now this is not implemented.
|
||||
SpeedBetterCompression = SpeedDefault
|
||||
|
||||
// SpeedBestCompression will choose the best available compression option.
|
||||
// For now this is not implemented.
|
||||
SpeedBestCompression = SpeedDefault
|
||||
)
|
||||
|
||||
// EncoderLevelFromString will convert a string representation of an encoding level back
|
||||
// to a compression level. The compare is not case sensitive.
|
||||
// If the string wasn't recognized, (false, SpeedDefault) will be returned.
|
||||
func EncoderLevelFromString(s string) (bool, EncoderLevel) {
|
||||
for l := EncoderLevel(speedNotSet + 1); l < speedLast; l++ {
|
||||
for l := speedNotSet + 1; l < speedLast; l++ {
|
||||
if strings.EqualFold(s, l.String()) {
|
||||
return true, l
|
||||
}
|
||||
@@ -162,8 +184,12 @@ func EncoderLevelFromZstd(level int) EncoderLevel {
|
||||
switch {
|
||||
case level < 3:
|
||||
return SpeedFastest
|
||||
case level >= 3:
|
||||
case level >= 3 && level < 6:
|
||||
return SpeedDefault
|
||||
case level >= 6 && level < 10:
|
||||
return SpeedBetterCompression
|
||||
case level >= 10:
|
||||
return SpeedBetterCompression
|
||||
}
|
||||
return SpeedDefault
|
||||
}
|
||||
@@ -175,6 +201,10 @@ func (e EncoderLevel) String() string {
|
||||
return "fastest"
|
||||
case SpeedDefault:
|
||||
return "default"
|
||||
case SpeedBetterCompression:
|
||||
return "better"
|
||||
case SpeedBestCompression:
|
||||
return "best"
|
||||
default:
|
||||
return "invalid"
|
||||
}
|
||||
@@ -188,6 +218,22 @@ func WithEncoderLevel(l EncoderLevel) EOption {
|
||||
return fmt.Errorf("unknown encoder level")
|
||||
}
|
||||
o.level = l
|
||||
if !o.customWindow {
|
||||
switch o.level {
|
||||
case SpeedFastest:
|
||||
o.windowSize = 4 << 20
|
||||
case SpeedDefault:
|
||||
o.windowSize = 8 << 20
|
||||
case SpeedBetterCompression:
|
||||
o.windowSize = 16 << 20
|
||||
case SpeedBestCompression:
|
||||
o.windowSize = 32 << 20
|
||||
}
|
||||
}
|
||||
if !o.customALEntropy {
|
||||
o.allLitEntropy = l > SpeedFastest
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -202,6 +248,28 @@ func WithZeroFrames(b bool) EOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithAllLitEntropyCompression will apply entropy compression if no matches are found.
|
||||
// Disabling this will skip incompressible data faster, but in cases with no matches but
|
||||
// skewed character distribution compression is lost.
|
||||
// Default value depends on the compression level selected.
|
||||
func WithAllLitEntropyCompression(b bool) EOption {
|
||||
return func(o *encoderOptions) error {
|
||||
o.customALEntropy = true
|
||||
o.allLitEntropy = b
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithNoEntropyCompression will always skip entropy compression of literals.
|
||||
// This can be useful if content has matches, but unlikely to benefit from entropy
|
||||
// compression. Usually the slight speed improvement is not worth enabling this.
|
||||
func WithNoEntropyCompression(b bool) EOption {
|
||||
return func(o *encoderOptions) error {
|
||||
o.noEntropy = b
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithSingleSegment will set the "single segment" flag when EncodeAll is used.
|
||||
// If this flag is set, data must be regenerated within a single continuous memory segment.
|
||||
// In this case, Window_Descriptor byte is skipped, but Frame_Content_Size is necessarily present.
|
||||
@@ -218,3 +286,27 @@ func WithSingleSegment(b bool) EOption {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithLowerEncoderMem will trade in some memory cases trade less memory usage for
|
||||
// slower encoding speed.
|
||||
// This will not change the window size which is the primary function for reducing
|
||||
// memory usage. See WithWindowSize.
|
||||
func WithLowerEncoderMem(b bool) EOption {
|
||||
return func(o *encoderOptions) error {
|
||||
o.lowMem = b
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithEncoderDict allows to register a dictionary that will be used for the encode.
|
||||
// The encoder *may* choose to use no dictionary instead for certain payloads.
|
||||
func WithEncoderDict(dict []byte) EOption {
|
||||
return func(o *encoderOptions) error {
|
||||
d, err := loadDict(dict)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.dict = d
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user