Skip to content

Commit

Permalink
fix: min,max keywords across codebase and move to go1.23 (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana authored Nov 19, 2024
1 parent 3d18966 commit 82bbf69
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.21.x, 1.22.x]
go-version: [1.23.x]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
Expand All @@ -37,7 +37,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.22.x
go-version: 1.23.x

- name: Checkout code
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.22.x
go-version: 1.23.x
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/vulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ 1.22.x ]
go-version: [ 1.23.x ]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down
8 changes: 4 additions & 4 deletions cli/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ func newClient(ctx *cli.Context) func() (cl *minio.Client, done func()) {
}
}
find := func() int {
min := math.MaxInt32
minSize := math.MaxInt32
for _, n := range running {
if n < min {
min = n
if n < minSize {
minSize = n
}
}
earliest := time.Now().Add(time.Second)
earliestIdx := 0
for i, n := range running {
if n == min {
if n == minSize {
if lastFinished[i].Before(earliest) {
earliest = lastFinished[i]
earliestIdx = i
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/minio/warp

go 1.21
go 1.23

require (
github.com/bygui86/multi-profile/v2 v2.1.0
Expand Down
26 changes: 13 additions & 13 deletions pkg/bench/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,22 +560,22 @@ func (o Operations) MultipleSizes() bool {
}

// MinMaxSize returns the minimum and maximum operation sizes.
func (o Operations) MinMaxSize() (min, max int64) {
func (o Operations) MinMaxSize() (minSize, maxSize int64) {
if len(o) == 0 {
return 0, 0
}

min = o[0].Size
max = o[0].Size
minSize = o[0].Size
maxSize = o[0].Size
for _, op := range o {
if op.Size < min {
min = op.Size
if op.Size < minSize {
minSize = op.Size
}
if op.Size > max {
max = op.Size
if op.Size > maxSize {
maxSize = op.Size
}
}
return min, max
return minSize, maxSize
}

// AvgSize returns the average operation size.
Expand Down Expand Up @@ -672,18 +672,18 @@ var log10ToLog2Size = map[int]int64{
}

func (o Operations) SingleSizeSegment() SizeSegment {
min, max := o.MinMaxSize()
minSize, maxSize := o.MinMaxSize()
var minL10, maxL10 int
for min > log10ToLog2Size[minL10+1] {
for minSize > log10ToLog2Size[minL10+1] {
minL10++
}
for max >= log10ToLog2Size[maxL10] {
for maxSize >= log10ToLog2Size[maxL10] {
maxL10++
}
return SizeSegment{
Smallest: min,
Smallest: minSize,
SmallestLog10: minL10,
Biggest: max,
Biggest: maxSize,
BiggestLog10: maxL10,
Ops: o,
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/generator/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ func (o CsvOpts) Comma(c byte) CsvOpts {
}

// FieldLen sets the length of each field.
func (o CsvOpts) FieldLen(min, max int) CsvOpts {
o.minLen = min
o.maxLen = max
func (o CsvOpts) FieldLen(minSize, maxSize int) CsvOpts {
o.minLen = minSize
o.maxLen = maxSize
return o
}

Expand Down
22 changes: 11 additions & 11 deletions pkg/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,24 @@ func randASCIIBytes(dst []byte, rng *rand.Rand) {
// GetExpRandSize will return an exponential random size from 1 to and including max.
// Minimum size: 127 bytes, max scale is 256 times smaller than max size.
// Average size will be max_size * 0.179151.
func GetExpRandSize(rng *rand.Rand, min, max int64) int64 {
if max-min < 10 {
if max-min <= 0 {
func GetExpRandSize(rng *rand.Rand, minSize, maxSize int64) int64 {
if maxSize-minSize < 10 {
if maxSize-minSize <= 0 {
return 0
}
return 1 + min + rng.Int63n(max-min)
return 1 + minSize + rng.Int63n(maxSize-minSize)
}
logSizeMax := math.Log2(float64(max - 1))
logSizeMin := math.Max(7, logSizeMax-8)
if min > 0 {
logSizeMin = math.Log2(float64(min - 1))
logSizeMaxSize := math.Log2(float64(maxSize - 1))
logSizeMinSize := math.Max(7, logSizeMaxSize-8)
if minSize > 0 {
logSizeMinSize = math.Log2(float64(minSize - 1))
}
lsDelta := logSizeMax - logSizeMin
lsDelta := logSizeMaxSize - logSizeMinSize
random := rng.Float64()
logSize := random * lsDelta
if logSize > 1 {
return 1 + int64(math.Pow(2, logSize+logSizeMin))
return 1 + int64(math.Pow(2, logSize+logSizeMinSize))
}
// For lowest part, do equal distribution
return 1 + min + int64(random*math.Pow(2, logSizeMin+1))
return 1 + minSize + int64(random*math.Pow(2, logSizeMinSize+1))
}
14 changes: 7 additions & 7 deletions pkg/generator/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,23 @@ func WithSizeHistograms(encoded string) Option {
}

// WithMinMaxSize sets the min and max size of the generated data.
func WithMinMaxSize(min, max int64) Option {
func WithMinMaxSize(minSize, maxSize int64) Option {
return func(o *Options) error {
if min <= 0 {
if minSize <= 0 {
return errors.New("WithMinMaxSize: minSize must be >= 0")
}
if max < 0 {
if maxSize < 0 {
return errors.New("WithMinMaxSize: maxSize must be > 0")
}
if min > max {
if minSize > maxSize {
return errors.New("WithMinMaxSize: minSize must be < maxSize")
}
if o.randSize && max < 256 {
if o.randSize && maxSize < 256 {
return errors.New("WithMinMaxSize: random sized objects should be at least 256 bytes")
}

o.totalSize = max
o.minSize = min
o.totalSize = maxSize
o.minSize = minSize
return nil
}
}
Expand Down

0 comments on commit 82bbf69

Please sign in to comment.