Skip to content

Commit 1f11fde

Browse files
author
Pavel Safonov
committed
default config if no hyper-threading available
1 parent e789882 commit 1f11fde

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

pkg/config.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ func initDefaultNumaConfig(config0 *config.Config) error {
115115
return nil
116116
}
117117

118+
nodesPhys, err := numa.GetNodesPhys()
119+
if err != nil {
120+
return err
121+
}
122+
l0 := len(nodesPhys[0].Cores[0].ThreadSiblings)
123+
if l0 == 0 {
124+
// no thread siblings, no hyper-threading
125+
return initDefaultLogicalPoolConfig(config0)
126+
}
127+
128+
return initDefaultPhysPoolConfig(config0)
129+
}
130+
131+
func initDefaultPhysPoolConfig(config0 *config.Config) error {
118132
nodesPhys, err := numa.GetNodesPhys()
119133
if err != nil {
120134
return err
@@ -156,6 +170,48 @@ func initDefaultNumaConfig(config0 *config.Config) error {
156170
return nil
157171
}
158172

173+
func initDefaultLogicalPoolConfig(config0 *config.Config) error {
174+
nodes, err := numa.GetNodes()
175+
if err != nil {
176+
return err
177+
}
178+
179+
node0 := nodes[0]
180+
181+
numaNodesCount := len(nodes)
182+
numaCoresCount := len(node0.Cpus)
183+
coresCount := getIdleCoresCountDefault(numaNodesCount, numaCoresCount)
184+
185+
idleCores := make([]int, 0, coresCount)
186+
for i := 0; i < coresCount; i++ {
187+
id := node0.Cpus[i]
188+
idleCores = append(idleCores, id)
189+
}
190+
191+
l1 := (numaNodesCount-1)*numaCoresCount + numaCoresCount - coresCount
192+
loadCores := make([]int, 0, l1)
193+
194+
for i := coresCount; i < numaCoresCount; i++ {
195+
id := node0.Cpus[i]
196+
loadCores = append(loadCores, id)
197+
}
198+
199+
for i := 1; i < numaNodesCount; i++ {
200+
node := nodes[i]
201+
for _, core := range node.Cpus {
202+
loadCores = append(loadCores, core)
203+
}
204+
}
205+
206+
pool := config0.Service.Pool
207+
pool.Idle.Values = idleCores
208+
pool.Load.Values = loadCores
209+
pool.LoadType = config.Logical
210+
211+
config0.Service.Pool = pool
212+
return nil
213+
}
214+
159215
func initDefaultFiltersConfig(config0 *config.Config) error {
160216
if len(config0.Service.Filters0) != 0 && len(config0.Service.Filters1) != 0 {
161217
return nil

pkg/config_defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ func getIdleCoresCountDefault(numaCount int, coresCount int) int {
1616
coresPart := getIdlePart(numaCount)
1717
coresCount0 := float64(coresCount)
1818
count := coresPart * coresCount0
19-
count0 := count + 0.01
19+
count0 := count + 0.001
2020
return int(count0)
2121
}

0 commit comments

Comments
 (0)