Skip to content

Conversation

@harp-intel
Copy link
Contributor

Summary

Split metadata collection logic into architecture-specific files to improve code organization and make it easier for new contributors to navigate the codebase.

Changes

File reorganization:

  • metadata.go - Common types, interfaces, script definitions, and shared helper functions
  • metadata_x86.go - x86_64 (Intel/AMD) metadata collector
  • metadata_aarch.go - ARM/aarch64 metadata collector

Code quality improvements:

  • Extract script name constants (16 total) to prevent silent failures from typos when accessing script outputs by name
  • Move script definitions to package-level baseMetadataScripts var for clearer separation from parameterization logic
  • Simplify getMetadataScripts() to copy and configure base definitions

Benefits

  • New developers can quickly find architecture-specific code
  • Script name typos now cause compile errors instead of silent runtime failures
  • Reduced file size: metadata.go went from ~1043 lines to ~513 lines
  • Clearer separation of concerns

Test plan

  • make test passes
  • go build ./... succeeds

Split metadata collection logic into architecture-specific files to
improve code organization and make it easier for new contributors to
navigate:

- metadata.go: Common types, interfaces, script definitions, and
  shared helper functions
- metadata_x86.go: x86_64 (Intel/AMD) metadata collector
- metadata_aarch.go: ARM/aarch64 metadata collector

Additional improvements:
- Extract script name constants to prevent silent failures from typos
- Move script definitions to package-level var for clearer separation
  from parameterization logic
- Simplify getMetadataScripts() to copy and configure base definitions

Signed-off-by: Jason Harper <[email protected]>
@harp-intel harp-intel force-pushed the refactor-metadata-by-architecture branch from 9a403ec to 597e6a8 Compare December 28, 2025 04:52
@harp-intel
Copy link
Contributor Author

Additional improvements in this update

  • Add scriptPerfStatFixedPrefix constant and use it in getSupportsFixedEvent()
  • Add defensive checks for cpuInfo map access in x86 collector (explicit key existence checks with clear error messages)
  • Fix ARM CPUSocketMap to support multi-socket systems by reading from sysfs instead of assuming single socket
  • Remove redundant warning logs in getARMSlots() (errors already convey the information)

Additional benefits

  • Better error messages when /proc/cpuinfo fields are missing
  • Correct CPU-to-socket mapping on multi-socket ARM systems

@harp-intel harp-intel merged commit 94f0cfb into main Dec 28, 2025
5 checks passed
@harp-intel harp-intel deleted the refactor-metadata-by-architecture branch December 28, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants