Skip to content

Commit e02c118

Browse files
authored
cache sizes reported by type (#506)
* cache sizes reported by type Signed-off-by: Harper, Jason M <[email protected]> * refactor Signed-off-by: Harper, Jason M <[email protected]> * address code review comments Signed-off-by: Harper, Jason M <[email protected]> * more refactoring Signed-off-by: Harper, Jason M <[email protected]> * increase precision Signed-off-by: Harper, Jason M <[email protected]> * config set only needs l3 instance size Signed-off-by: Harper, Jason M <[email protected]> --------- Signed-off-by: Harper, Jason M <[email protected]>
1 parent 6f99f42 commit e02c118

File tree

5 files changed

+250
-327
lines changed

5 files changed

+250
-327
lines changed

cmd/config/set.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ func setLlcSize(desiredLlcSize float64, myTarget target.Target, localTempDir str
121121
// get the data we need to set the LLC size
122122
scripts := []script.ScriptDefinition{}
123123
scripts = append(scripts, script.GetScriptByName(script.LscpuScriptName))
124+
scripts = append(scripts, script.GetScriptByName(script.LscpuCacheScriptName))
124125
scripts = append(scripts, script.GetScriptByName(script.LspciBitsScriptName))
125126
scripts = append(scripts, script.GetScriptByName(script.LspciDevicesScriptName))
126127
scripts = append(scripts, script.GetScriptByName(script.L3CacheWayEnabledName))
@@ -140,12 +141,12 @@ func setLlcSize(desiredLlcSize float64, myTarget target.Target, localTempDir str
140141
completeChannel <- setOutput{goRoutineID: goRoutineId, err: fmt.Errorf("cache way count is zero")}
141142
return
142143
}
143-
maximumLlcSize, err := report.GetL3LscpuMB(outputs)
144+
maximumLlcSize, _, err := report.GetL3LscpuMB(outputs)
144145
if err != nil {
145146
completeChannel <- setOutput{goRoutineID: goRoutineId, err: fmt.Errorf("failed to get maximum LLC size: %w", err)}
146147
return
147148
}
148-
currentLlcSize, err := report.GetL3MSRMB(outputs)
149+
currentLlcSize, _, err := report.GetL3MSRMB(outputs)
149150
if err != nil {
150151
completeChannel <- setOutput{goRoutineID: goRoutineId, err: fmt.Errorf("failed to get current LLC size: %w", err)}
151152
return

internal/report/table_defs.go

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ var tableDefinitions = map[string]TableDefinition{
222222
MenuLabel: CPUMenuLabel,
223223
ScriptNames: []string{
224224
script.LscpuScriptName,
225+
script.LscpuCacheScriptName,
225226
script.LspciBitsScriptName,
226227
script.LspciDevicesScriptName,
227228
script.CpuidScriptName,
@@ -502,6 +503,7 @@ var tableDefinitions = map[string]TableDefinition{
502503
script.DateScriptName,
503504
script.DmidecodeScriptName,
504505
script.LscpuScriptName,
506+
script.LscpuCacheScriptName,
505507
script.LspciBitsScriptName,
506508
script.LspciDevicesScriptName,
507509
script.L3CacheWayEnabledName,
@@ -537,6 +539,7 @@ var tableDefinitions = map[string]TableDefinition{
537539
script.HostnameScriptName,
538540
script.DateScriptName,
539541
script.LscpuScriptName,
542+
script.LscpuCacheScriptName,
540543
script.LspciBitsScriptName,
541544
script.LspciDevicesScriptName,
542545
script.MaximumFrequencyScriptName,
@@ -563,6 +566,7 @@ var tableDefinitions = map[string]TableDefinition{
563566
HasRows: false,
564567
ScriptNames: []string{
565568
script.LscpuScriptName,
569+
script.LscpuCacheScriptName,
566570
script.LspciBitsScriptName,
567571
script.LspciDevicesScriptName,
568572
script.L3CacheWayEnabledName,
@@ -997,6 +1001,21 @@ func softwareVersionTableValues(outputs map[string]script.ScriptOutput) []Field
9971001
}
9981002

9991003
func cpuTableValues(outputs map[string]script.ScriptOutput) []Field {
1004+
var l1d, l1i, l2 string
1005+
lscpuCache, err := parseLscpuCacheOutput(outputs[script.LscpuCacheScriptName].Stdout)
1006+
if err != nil {
1007+
slog.Warn("failed to parse lscpu cache output", "error", err)
1008+
} else {
1009+
if _, ok := lscpuCache["L1d"]; ok {
1010+
l1d = l1l2CacheSizeFromLscpuCache(lscpuCache["L1d"])
1011+
}
1012+
if _, ok := lscpuCache["L1i"]; ok {
1013+
l1i = l1l2CacheSizeFromLscpuCache(lscpuCache["L1i"])
1014+
}
1015+
if _, ok := lscpuCache["L2"]; ok {
1016+
l2 = l1l2CacheSizeFromLscpuCache(lscpuCache["L2"])
1017+
}
1018+
}
10001019
return []Field{
10011020
{Name: "CPU Model", Values: []string{valFromRegexSubmatch(outputs[script.LscpuScriptName].Stdout, `^[Mm]odel name:\s*(.+)$`)}},
10021021
{Name: "Architecture", Values: []string{valFromRegexSubmatch(outputs[script.LscpuScriptName].Stdout, `^Architecture:\s*(.+)$`)}},
@@ -1014,11 +1033,11 @@ func cpuTableValues(outputs map[string]script.ScriptOutput) []Field {
10141033
{Name: "Sockets", Values: []string{valFromRegexSubmatch(outputs[script.LscpuScriptName].Stdout, `^Socket\(s\):\s*(.+)$`)}},
10151034
{Name: "NUMA Nodes", Values: []string{valFromRegexSubmatch(outputs[script.LscpuScriptName].Stdout, `^NUMA node\(s\):\s*(.+)$`)}},
10161035
{Name: "NUMA CPU List", Values: []string{numaCPUListFromOutput(outputs)}},
1017-
{Name: "L1d Cache", Values: []string{l1dFromOutput(outputs)}, Description: "The sum of all L1 data cache sizes for one CPU socket."},
1018-
{Name: "L1i Cache", Values: []string{l1iFromOutput(outputs)}, Description: "The sum of all L1 instruction cache sizes for one CPU socket."},
1019-
{Name: "L2 Cache", Values: []string{l2FromOutput(outputs)}, Description: "The sum of all L2 cache sizes for one CPU socket."},
1020-
{Name: "L3 Cache", Values: []string{l3FromOutput(outputs)}, Description: "The total L3 cache size for one CPU socket."},
1021-
{Name: "L3 per Core", Values: []string{l3PerCoreFromOutput(outputs)}, Description: "The L3 cache size per CPU core."},
1036+
{Name: "L1d Cache", Values: []string{l1d}, Description: "The size of the L1 data cache for one core."},
1037+
{Name: "L1i Cache", Values: []string{l1i}, Description: "The size of the L1 instruction cache for one core."},
1038+
{Name: "L2 Cache", Values: []string{l2}, Description: "The size of the L2 cache for one core."},
1039+
{Name: "L3 Cache (instance/total)", Values: []string{l3FromOutput(outputs)}, Description: "The size of one L3 cache instance and the total L3 cache size for the system."},
1040+
{Name: "L3 per Core", Values: []string{l3PerCoreFromOutput(outputs)}, Description: "The L3 cache size per core."},
10221041
{Name: "Memory Channels", Values: []string{channelsFromOutput(outputs)}},
10231042
{Name: "Intel Turbo Boost", Values: []string{turboEnabledFromOutput(outputs)}},
10241043
{Name: "Virtualization", Values: []string{valFromRegexSubmatch(outputs[script.LscpuScriptName].Stdout, `^Virtualization:\s*(.+)$`)}},
@@ -1983,7 +2002,7 @@ func systemSummaryTableValues(outputs map[string]script.ScriptOutput) []Field {
19832002
{Name: "CPU Model", Values: []string{valFromRegexSubmatch(outputs[script.LscpuScriptName].Stdout, `^[Mm]odel name:\s*(.+)$`)}},
19842003
{Name: "Architecture", Values: []string{valFromRegexSubmatch(outputs[script.LscpuScriptName].Stdout, `^Architecture:\s*(.+)$`)}},
19852004
{Name: "Microarchitecture", Values: []string{UarchFromOutput(outputs)}},
1986-
{Name: "L3 Cache", Values: []string{l3FromOutput(outputs)}, Description: "The total L3 cache size for one CPU socket."},
2005+
{Name: "L3 Cache (instance/total)", Values: []string{l3FromOutput(outputs)}, Description: "The size of one L3 cache instance and the total L3 cache size for the system."},
19872006
{Name: "Cores per Socket", Values: []string{valFromRegexSubmatch(outputs[script.LscpuScriptName].Stdout, `^Core\(s\) per socket:\s*(.+)$`)}},
19882007
{Name: "Sockets", Values: []string{valFromRegexSubmatch(outputs[script.LscpuScriptName].Stdout, `^Socket\(s\):\s*(.+)$`)}},
19892008
{Name: "Hyperthreading", Values: []string{hyperthreadingFromOutput(outputs)}},
@@ -2053,7 +2072,7 @@ func configurationTableValues(outputs map[string]script.ScriptOutput) []Field {
20532072

20542073
fields := []Field{
20552074
{Name: "Cores per Socket", Values: []string{valFromRegexSubmatch(outputs[script.LscpuScriptName].Stdout, `^Core\(s\) per socket:\s*(.+)$`)}},
2056-
{Name: "L3 Cache", Values: []string{l3FromOutput(outputs)}},
2075+
{Name: "L3 Cache", Values: []string{l3InstanceFromOutput(outputs)}},
20572076
{Name: "Package Power / TDP", Values: []string{tdpFromOutput(outputs)}},
20582077
{Name: "All-Core Max Frequency", Values: []string{allCoreMaxFrequencyFromOutput(outputs)}},
20592078
}

0 commit comments

Comments
 (0)