jonhoo / jonhoo/inferno

Scaling factor should support fractional values

Open
#243 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.2k
Forks
160
PR merge metrics
No merged PRs in 30d

Description

I see that from #19 the decision was made to match the Perl implementation by truncating integers. This was perhaps in part due to an "accumulation of error" from [#18](https://github.com/brendangregg/FlameGraph/pull/18)

But, the [documentation](https://docs.rs/inferno/0.11.3/inferno/flamegraph/struct.Options.html#structfield.factor) specifies that

> For example, if you have 23.4 as a sample count you can upscale it to 234, then set factor to 0.1

Which implies that decimal points are supported.

In [firestorm](https://crates.io/crates/firestorm) the units are in nanoseconds. At least on my computer, the minimum resolution for a sample is 100ns. To "unclutter" the text, I would like to display microseconds instead with fractional values. Eg: instead of 17,100ns, show 17.1μs. This would require fractional values to do well. The current behavior sometimes ends up truncating values to 0.

The accumulation of error can be avoided by not using floating point for calculations throughout, but instead only use the `factor` at the last moment when formatting the SVG text.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with inferno::flamegraph::Options.factor and trace how the scaling factor reaches SVG text formatting. Compare the documented fractional example with the current truncation behavior and the firestorm nanosecond use case. Done means fractional factors produce nonzero decimal display values without accumulating calculation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
data-visualization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.