parse_percent_values always setting percentage to 0 doing double multiplication to 1024
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 24.1k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 365
Description
I was investigating what procfs was used for and I was looking into the implementation of reading the total amount of memory and saw that we multiply the output by 1024 even though the output is already returned in bytes by procfs.
The second bug I saw in the implementation is that this was implemented as an int:
Ok(total) => Ok((number / 100) * total),
Which always equals 0 and it needs to be changed to this:
Ok(total) => Ok(total * number / 100),
Taking a look at the implementation of how procfs reads these values its very simple and the dependency chain for procfs is massive and brings in other large dependencies such as chrono that we do not use anymore.
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
Start at the parse_percent_values implementation and trace how procfs supplies total memory and percentage values. Verify the units and integer arithmetic, then inspect the procfs dependency chain; done means percentage calculations are nonzero and memory is not multiplied by 1024 twice, with the unnecessary dependency concerns addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100