@@ -56,6 +56,16 @@ type SupraSealConfig struct {
56
56
P2HcP2RdOverlap bool
57
57
}
58
58
59
+ type AdditionalSystemInfo struct {
60
+ CPUName string
61
+ MemorySize string
62
+ MemoryChannels int
63
+ InstalledModules int
64
+ MaxMemoryCapacity string
65
+ MemoryType string
66
+ MemorySpeed string
67
+ }
68
+
59
69
func GetSystemInfo () (* SystemInfo , error ) {
60
70
cmd := exec .Command ("hwloc-ls" )
61
71
output , err := cmd .Output ()
@@ -246,17 +256,40 @@ func GenerateSupraSealConfig(info SystemInfo, dualHashers bool, batchSize int, n
246
256
return config , nil
247
257
}
248
258
249
- func FormatSupraSealConfig (config SupraSealConfig ) string {
259
+ func FormatSupraSealConfig (config SupraSealConfig , system SystemInfo , additionalInfo AdditionalSystemInfo ) string {
250
260
var sb strings.Builder
251
261
252
262
w := func (s string ) { sb .WriteString (s ); sb .WriteByte ('\n' ) }
253
263
254
264
w ("# Configuration for supra_seal" )
265
+ w ("" )
266
+ w ("# Machine Specifications:" )
267
+ w (fmt .Sprintf ("# CPU: %s" , additionalInfo .CPUName ))
268
+ w (fmt .Sprintf ("# Memory: %s" , additionalInfo .MemorySize ))
269
+ w (fmt .Sprintf ("# Memory Type: %s" , additionalInfo .MemoryType ))
270
+ w (fmt .Sprintf ("# Memory Speed: %s" , additionalInfo .MemorySpeed ))
271
+ w (fmt .Sprintf ("# Installed Memory Modules: %d" , additionalInfo .InstalledModules ))
272
+ w (fmt .Sprintf ("# Maximum Memory Capacity: %s" , additionalInfo .MaxMemoryCapacity ))
273
+ w (fmt .Sprintf ("# Memory Channels: %d" , additionalInfo .MemoryChannels ))
274
+ w (fmt .Sprintf ("# Processor Count: %d" , system .ProcessorCount ))
275
+ w (fmt .Sprintf ("# Core Count: %d" , system .CoreCount ))
276
+ w (fmt .Sprintf ("# Threads per Core: %d" , system .ThreadsPerCore ))
277
+ w (fmt .Sprintf ("# Cores per L3 Cache: %d" , system .CoresPerL3 ))
278
+ w ("" )
279
+ w ("# Diagnostic Information:" )
280
+ w (fmt .Sprintf ("# Required Threads: %d" , config .RequiredThreads ))
281
+ w (fmt .Sprintf ("# Required CCX: %d" , config .RequiredCCX ))
282
+ w (fmt .Sprintf ("# Required Cores: %d" , config .RequiredCores ))
283
+ w (fmt .Sprintf ("# Unoccupied Cores: %d" , config .UnoccupiedCores ))
284
+ w (fmt .Sprintf ("# P2 Writer/Reader Overlap: %v" , config .P2WrRdOverlap ))
285
+ w (fmt .Sprintf ("# P2 Hasher/P1 Writer Overlap: %v" , config .P2HsP1WrOverlap ))
286
+ w (fmt .Sprintf ("# P2 Hasher CPU/P2 Reader Overlap: %v" , config .P2HcP2RdOverlap ))
287
+ w ("" )
255
288
w ("spdk: {" )
256
289
w (" # PCIe identifiers of NVMe drives to use to store layers" )
257
290
w (" nvme = [ " )
258
291
259
- quotedNvme := lo .Map (config .NVMeDevices , func (d string , i int ) string { return ` "` + d + `"` })
292
+ quotedNvme := lo .Map (config .NVMeDevices , func (d string , _ int ) string { return ` "` + d + `"` })
260
293
w (strings .Join (quotedNvme , ",\n " ))
261
294
262
295
w (" ];" )
@@ -276,26 +309,19 @@ func FormatSupraSealConfig(config SupraSealConfig) string {
276
309
w (" hashers_per_core = 2;" )
277
310
w ("" )
278
311
w (" sector_configs: (" )
279
- for i , sectorConfig := range config .Topology .SectorConfigs {
280
- w (" {" )
281
- w (fmt .Sprintf (" sectors = %d;" , sectorConfig .Sectors ))
282
- w (" coordinators = (" )
283
- for i , coord := range sectorConfig .Coordinators {
284
- sb .WriteString (fmt .Sprintf (" { core = %d;\n " , coord .Core ))
285
- sb .WriteString (fmt .Sprintf (" hashers = %d; }" , coord .Hashers ))
286
- if i < len (sectorConfig .Coordinators )- 1 {
287
- sb .WriteString ("," )
288
- }
289
- sb .WriteByte ('\n' )
290
- }
291
- w (" )" )
292
- sb .WriteString (" }" )
293
312
294
- if i < len (config .Topology .SectorConfigs )- 1 {
295
- sb .WriteString ("," )
296
- }
297
- sb .WriteByte ('\n' )
298
- }
313
+ sectorConfigsStr := lo .Map (config .Topology .SectorConfigs , func (sectorConfig SectorConfig , i int ) string {
314
+ coordsStr := lo .Map (sectorConfig .Coordinators , func (coord CoordinatorConfig , j int ) string {
315
+ return fmt .Sprintf (" { core = %d;\n hashers = %d; }%s\n " ,
316
+ coord .Core , coord .Hashers , lo .Ternary (j < len (sectorConfig .Coordinators )- 1 , "," , "" ))
317
+ })
318
+
319
+ return fmt .Sprintf (" {\n sectors = %d;\n coordinators = (\n %s )\n }%s\n " ,
320
+ sectorConfig .Sectors , strings .Join (coordsStr , "" ), lo .Ternary (i < len (config .Topology .SectorConfigs )- 1 , "," , "" ))
321
+ })
322
+
323
+ w (strings .Join (sectorConfigsStr , "" ))
324
+
299
325
w (" )" )
300
326
w (" }," )
301
327
w ("" )
@@ -318,3 +344,83 @@ func FormatSupraSealConfig(config SupraSealConfig) string {
318
344
319
345
return sb .String ()
320
346
}
347
+
348
+ func ExtractAdditionalSystemInfo () (AdditionalSystemInfo , error ) {
349
+ info := AdditionalSystemInfo {}
350
+
351
+ // Extract CPU Name (unchanged)
352
+ cpuInfoCmd := exec .Command ("lscpu" )
353
+ cpuInfoOutput , err := cpuInfoCmd .Output ()
354
+ if err != nil {
355
+ return info , fmt .Errorf ("failed to execute lscpu: %v" , err )
356
+ }
357
+
358
+ cpuInfoLines := strings .Split (string (cpuInfoOutput ), "\n " )
359
+ for _ , line := range cpuInfoLines {
360
+ if strings .HasPrefix (line , "Model name:" ) {
361
+ info .CPUName = strings .TrimSpace (strings .TrimPrefix (line , "Model name:" ))
362
+ break
363
+ }
364
+ }
365
+
366
+ // Extract Memory Information
367
+ memInfoCmd := exec .Command ("dmidecode" , "-t" , "memory" )
368
+ memInfoOutput , err := memInfoCmd .Output ()
369
+ if err != nil {
370
+ log .Warnf ("failed to execute dmidecode: %v" , err )
371
+ return info , nil
372
+ }
373
+
374
+ memInfoLines := strings .Split (string (memInfoOutput ), "\n " )
375
+ var totalMemory int64
376
+ for _ , line := range memInfoLines {
377
+ line = strings .TrimSpace (line )
378
+ if strings .HasPrefix (line , "Maximum Capacity:" ) {
379
+ info .MaxMemoryCapacity = strings .TrimSpace (strings .TrimPrefix (line , "Maximum Capacity:" ))
380
+ } else if strings .HasPrefix (line , "Number Of Devices:" ) {
381
+ info .MemoryChannels , _ = strconv .Atoi (strings .TrimSpace (strings .TrimPrefix (line , "Number Of Devices:" )))
382
+ } else if strings .HasPrefix (line , "Size:" ) {
383
+ if strings .Contains (line , "GB" ) {
384
+ sizeStr := strings .TrimSpace (strings .TrimSuffix (strings .TrimPrefix (line , "Size:" ), "GB" ))
385
+ size , _ := strconv .ParseInt (sizeStr , 10 , 64 )
386
+ if size > 0 {
387
+ totalMemory += size
388
+ info .InstalledModules ++
389
+ }
390
+ }
391
+ } else if strings .HasPrefix (line , "Type:" ) && info .MemoryType == "" {
392
+ info .MemoryType = strings .TrimSpace (strings .TrimPrefix (line , "Type:" ))
393
+ } else if strings .HasPrefix (line , "Speed:" ) && info .MemorySpeed == "" {
394
+ info .MemorySpeed = strings .TrimSpace (strings .TrimPrefix (line , "Speed:" ))
395
+ }
396
+ }
397
+
398
+ info .MemorySize = fmt .Sprintf ("%d GB" , totalMemory )
399
+
400
+ return info , nil
401
+ }
402
+
403
+ func GenerateSupraSealConfigString (dualHashers bool , batchSize int , nvmeDevices []string ) (string , error ) {
404
+ // Get system information
405
+ sysInfo , err := GetSystemInfo ()
406
+ if err != nil {
407
+ return "" , fmt .Errorf ("failed to get system info: %v" , err )
408
+ }
409
+
410
+ // Generate SupraSealConfig
411
+ config , err := GenerateSupraSealConfig (* sysInfo , dualHashers , batchSize , nvmeDevices )
412
+ if err != nil {
413
+ return "" , fmt .Errorf ("failed to generate SupraSeal config: %v" , err )
414
+ }
415
+
416
+ // Get additional system information
417
+ additionalInfo , err := ExtractAdditionalSystemInfo ()
418
+ if err != nil {
419
+ return "" , fmt .Errorf ("failed to extract additional system info: %v" , err )
420
+ }
421
+
422
+ // Format the config
423
+ configString := FormatSupraSealConfig (config , * sysInfo , additionalInfo )
424
+
425
+ return configString , nil
426
+ }
0 commit comments