CPU peak memory calculation overestimates memory usage by 100x
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1k
- Forks
- 346
- PR merge metrics
- No merged PRs in 30d
Description
In torchbenchmark/util/experiment/metrics.py, the CPU memory calculation in get_peak_memory() currently uses:
cpu_peak_mem = percentage * total / 10**9
psutil.Process.memory_percent() returns a percentage (for example, 5.0 means 5%), not a ratio between 0 and 1. Multiplying this value directly by total system memory causes the reported cpu_peak_mem to be 100x too large.
The conversion should divide the percentage by 100:
cpu_peak_mem = percentage * total / 100 / 10**9
For example, 5% of 100 GB should be reported as 5 GB, but the current formula reports 500 GB.
Related PR: #2706. The proposed fix only corrects the unit conversion and does not change the existing CPU peak memory measurement behavior.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open torchbenchmark/util/experiment/metrics.py and start at get_peak_memory(), focusing on the CPU memory calculation and the percentage returned by psutil.Process.memory_percent(). Correct the percent-to-ratio conversion so a 5% reading from a 100 GB system reports 5 GB rather than 500 GB. Done means the calculation changes only the unit conversion described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 92/100