Skip to content

Add WithDisableTopology option to reduce memory consumption#449

Merged
jaypipes merged 1 commit intomainfrom
pr-432
Feb 9, 2026
Merged

Add WithDisableTopology option to reduce memory consumption#449
jaypipes merged 1 commit intomainfrom
pr-432

Conversation

@jaypipes
Copy link
Copy Markdown
Owner

@jaypipes jaypipes commented Feb 9, 2026

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 <hackzhuyan@gmail.com>
@jaypipes jaypipes merged commit a1141de into main Feb 9, 2026
21 checks passed
@jaypipes jaypipes deleted the pr-432 branch February 9, 2026 13:37
@jaypipes
Copy link
Copy Markdown
Owner Author

jaypipes commented Feb 9, 2026

@halfcrazy thank you very much for your contribution! welcome to the ghw contributors membership :)

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