mirror of
https://github.com/minio/minio.git
synced 2025-02-10 05:08:10 -05:00
* Prevent unnecessary verification of parity blocks while reading erasure coded file. * Update klauspost/reedsolomon and just only reconstruct data blocks while reading (prevent unnecessary parity block reconstruction) * Remove Verification of (all) reconstructed Data and Parity blocks since in our case we are protected by bit rot protection. And even if the verification would fail (essentially impossible) there is no way to definitively say whether the data is still correct or not, so this call make no sense for our use case.
79 lines
1.7 KiB
Go
79 lines
1.7 KiB
Go
package reedsolomon
|
|
|
|
import (
|
|
"runtime"
|
|
|
|
"github.com/klauspost/cpuid"
|
|
)
|
|
|
|
// Option allows to override processing parameters.
|
|
type Option func(*options)
|
|
|
|
type options struct {
|
|
maxGoroutines int
|
|
minSplitSize int
|
|
useAVX2, useSSSE3 bool
|
|
usePAR1Matrix bool
|
|
}
|
|
|
|
var defaultOptions = options{
|
|
maxGoroutines: 50,
|
|
minSplitSize: 512,
|
|
}
|
|
|
|
func init() {
|
|
if runtime.GOMAXPROCS(0) <= 1 {
|
|
defaultOptions.maxGoroutines = 1
|
|
}
|
|
// Detect CPU capabilities.
|
|
defaultOptions.useSSSE3 = cpuid.CPU.SSSE3()
|
|
defaultOptions.useAVX2 = cpuid.CPU.AVX2()
|
|
}
|
|
|
|
// WithMaxGoroutines is the maximum number of goroutines number for encoding & decoding.
|
|
// Jobs will be split into this many parts, unless each goroutine would have to process
|
|
// less than minSplitSize bytes (set with WithMinSplitSize).
|
|
// For the best speed, keep this well above the GOMAXPROCS number for more fine grained
|
|
// scheduling.
|
|
// If n <= 0, it is ignored.
|
|
func WithMaxGoroutines(n int) Option {
|
|
return func(o *options) {
|
|
if n > 0 {
|
|
o.maxGoroutines = n
|
|
}
|
|
}
|
|
}
|
|
|
|
// WithMinSplitSize is the minimum encoding size in bytes per goroutine.
|
|
// See WithMaxGoroutines on how jobs are split.
|
|
// If n <= 0, it is ignored.
|
|
func WithMinSplitSize(n int) Option {
|
|
return func(o *options) {
|
|
if n > 0 {
|
|
o.minSplitSize = n
|
|
}
|
|
}
|
|
}
|
|
|
|
func withSSE3(enabled bool) Option {
|
|
return func(o *options) {
|
|
o.useSSSE3 = enabled
|
|
}
|
|
}
|
|
|
|
func withAVX2(enabled bool) Option {
|
|
return func(o *options) {
|
|
o.useAVX2 = enabled
|
|
}
|
|
}
|
|
|
|
// WithPAR1Matrix causes the encoder to build the matrix how PARv1
|
|
// does. Note that the method they use is buggy, and may lead to cases
|
|
// where recovery is impossible, even if there are enough parity
|
|
// shards.
|
|
func WithPAR1Matrix() Option {
|
|
return func(o *options) {
|
|
o.usePAR1Matrix = true
|
|
}
|
|
}
|