Merge pull request #77421 from tedyu/cpu-free-no-sort
Obtain unsorted slice in cpuAccumulator#freeCores
This commit is contained in:
		| @@ -69,7 +69,7 @@ func (a *cpuAccumulator) freeSockets() []int { | |||||||
| // - socket ID, ascending | // - socket ID, ascending | ||||||
| // - core ID, ascending | // - core ID, ascending | ||||||
| func (a *cpuAccumulator) freeCores() []int { | func (a *cpuAccumulator) freeCores() []int { | ||||||
| 	socketIDs := a.details.Sockets().ToSlice() | 	socketIDs := a.details.Sockets().ToSliceNoSort() | ||||||
| 	sort.Slice(socketIDs, | 	sort.Slice(socketIDs, | ||||||
| 		func(i, j int) bool { | 		func(i, j int) bool { | ||||||
| 			iCores := a.details.CoresInSocket(socketIDs[i]).Filter(a.isCoreFree) | 			iCores := a.details.CoresInSocket(socketIDs[i]).Filter(a.isCoreFree) | ||||||
|   | |||||||
| @@ -188,6 +188,16 @@ func (s CPUSet) ToSlice() []int { | |||||||
| 	return result | 	return result | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // ToSliceNoSort returns a slice of integers that contains all elements from | ||||||
|  | // this set. | ||||||
|  | func (s CPUSet) ToSliceNoSort() []int { | ||||||
|  | 	result := []int{} | ||||||
|  | 	for cpu := range s.elems { | ||||||
|  | 		result = append(result, cpu) | ||||||
|  | 	} | ||||||
|  | 	return result | ||||||
|  | } | ||||||
|  |  | ||||||
| // String returns a new string representation of the elements in this CPU set | // String returns a new string representation of the elements in this CPU set | ||||||
| // in canonical linux CPU list format. | // in canonical linux CPU list format. | ||||||
| // | // | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot