Skip to content

Conversation

@halfcrazy
Copy link

@halfcrazy halfcrazy commented Nov 6, 2025

This commit adds a new WithDisableTopology() option that allows users to skip system topology detection when calling ghw.PCI() or ghw.GPU(), significantly reducing memory consumption for use cases that don't require NUMA topology information.

Performance impact on real production servers:

Dual-socket server (2 NUMA nodes, 96 cores):
BenchmarkPCIMemoryComparison/WithTopologyDetection 100 100708875 ns/op 29332384 B/op 289365 allocs/op
BenchmarkPCIMemoryComparison/WithDisableTopology 100 58473485 ns/op 17201283 B/op 247006 allocs/op

  • Memory: 41% reduction (28 MB -> 16.4 MB)
  • Time: 42% faster (100.7 ms -> 58.5 ms)
  • Allocations: 15% fewer (289,365 -> 247,006)

Quad-socket server (4 NUMA nodes, 128 cores):
BenchmarkPCIMemoryComparison/WithTopologyDetection 100 448132406 ns/op 344566098 B/op 257009 allocs/op
BenchmarkPCIMemoryComparison/WithDisableTopology 100 64284435 ns/op 18707107 B/op 193877 allocs/op

  • Memory: 94.6% reduction (328 MB -> 17.8 MB)
  • Time: 85.7% faster (448 ms -> 64 ms)
  • Allocations: 24.6% fewer (257,009 -> 193,877)
  • Saves 310 MB per call - critical for large deployments

This commit adds a new WithDisableTopology() option that allows users
to skip system topology detection when calling ghw.PCI() or ghw.GPU(),
significantly reducing memory consumption for use cases that don't
require NUMA topology information.

Signed-off-by: Yan Zhu <[email protected]>
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.

1 participant