diff --git a/go.mod b/go.mod index 6b839b6530..caacfe83b8 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.1.0 - github.com/intel/goresctrl v0.12.0 + github.com/intel/goresctrl v0.13.0 github.com/klauspost/compress v1.18.6 github.com/mdlayher/vsock v1.2.1 github.com/moby/locker v1.0.1 diff --git a/go.sum b/go.sum index ada379607c..aded2a869f 100644 --- a/go.sum +++ b/go.sum @@ -192,8 +192,8 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/intel/goresctrl v0.12.0 h1:F44m7jiVgOdqWfTTWaREF+5HTeX3i06qhvpuzpnrBko= -github.com/intel/goresctrl v0.12.0/go.mod h1:5GWtmPY4BWl/a9rU8apGED9Xul5b5WoLtg/qOWaghWU= +github.com/intel/goresctrl v0.13.0 h1:5fhKjNq4V5MYDFHa//6M6x0jP6Iq5EXwZc6/eYxdEtQ= +github.com/intel/goresctrl v0.13.0/go.mod h1:KFHS91JGOmeeuEog+nTQcsGjLC81nRqdsdhcqf69fjU= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA= diff --git a/vendor/github.com/intel/goresctrl/pkg/utils/idset.go b/vendor/github.com/intel/goresctrl/pkg/utils/idset.go index 41d7fc91fe..d31d17ab02 100644 --- a/vendor/github.com/intel/goresctrl/pkg/utils/idset.go +++ b/vendor/github.com/intel/goresctrl/pkg/utils/idset.go @@ -173,33 +173,45 @@ func (s IDSet) SortedMembers() []ID { return ids } -// String returns the set as a string. +// String returns the set as a string in packed range format (e.g. "0,2-4,7-8,10"). func (s IDSet) String() string { return s.StringWithSeparator(",") } -// StringWithSeparator returns the set as a string, separated with the given separator. +// StringWithSeparator returns the set as a packed range string using the given separator +// between groups (e.g. separator "," gives "0,2-4,7-8,10"). func (s IDSet) StringWithSeparator(args ...string) string { if len(s) == 0 { return "" } - var sep string - + sep := "," if len(args) == 1 { sep = args[0] + } + + sorted := s.SortedMembers() + var parts []string + start, end := sorted[0], sorted[0] + for _, id := range sorted[1:] { + if id == end+1 { + end = id + } else { + if end > start { + parts = append(parts, strconv.Itoa(start)+"-"+strconv.Itoa(end)) + } else { + parts = append(parts, strconv.Itoa(start)) + } + start, end = id, id + } + } + if end > start { + parts = append(parts, strconv.Itoa(start)+"-"+strconv.Itoa(end)) } else { - sep = "," + parts = append(parts, strconv.Itoa(start)) } - str := "" - t := "" - for _, id := range s.SortedMembers() { - str = str + t + strconv.Itoa(int(id)) - t = sep - } - - return str + return strings.Join(parts, sep) } // MarshalJSON is the JSON marshaller for IDSet. @@ -214,18 +226,10 @@ func (s *IDSet) UnmarshalJSON(data []byte) error { return fmt.Errorf("invalid IDSet entry '%s': %v", string(data), err) } - *s = NewIDSet() - if str == "" { - return nil + parsed, err := NewIDSetFromString(str) + if err != nil { + return fmt.Errorf("invalid IDSet entry '%s': %v", str, err) } - - for _, idstr := range strings.Split(str, ",") { - id, err := strconv.ParseInt(idstr, 10, 0) - if err != nil { - return fmt.Errorf("invalid IDSet entry '%s': %v", idstr, err) - } - s.Add(ID(id)) - } - + *s = parsed return nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index 2a6d1b258f..423b3a7fe1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -369,7 +369,7 @@ github.com/grpc-ecosystem/grpc-gateway/v2/runtime github.com/grpc-ecosystem/grpc-gateway/v2/utilities # github.com/hashicorp/errwrap v1.1.0 ## explicit -# github.com/intel/goresctrl v0.12.0 +# github.com/intel/goresctrl v0.13.0 ## explicit; go 1.25.0 github.com/intel/goresctrl/pkg/blockio github.com/intel/goresctrl/pkg/kubernetes