Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace pretty_toa with num-format. #38

Merged
merged 6 commits into from
Feb 20, 2019
Merged

Replace pretty_toa with num-format. #38

merged 6 commits into from
Feb 20, 2019

Conversation

bcmyers
Copy link
Contributor

@bcmyers bcmyers commented Feb 7, 2019

Unlike pretty_toa, num-format can create
a &str representation of a number (with
thousands separators) without allocating.

Creating this kind of string representation from
a number only occurs at one place in inferno's
code; so replacing pretty_toa with num-format
is a tiny improvement, but it is an improvement
nontheless as it avoids an unnecessary allocation
(which occurs in a loop).

Fixes #29.

Unlike pretty_toa, num-format can create
a &str representation of a number (with
thousands separators) without allocating.

Creating this kind of string representation from
a number only occurs at one place in inferno's
code; so replacing pretty_toa with num-format
is a tiny improvement, but it is an improvement
nontheless as it avoids an unnecessary allocation
(which occurs in a loop).

Fixes jonhoo#29.
@bcmyers
Copy link
Contributor Author

bcmyers commented Feb 7, 2019

Your Windows CI identified a small bug in num-format (thanks!). It was implementing a trait unconditionally on a unix-only type (instead of putting it behind a #[cfg(unix)] flag). I’m publishing a bug fix update to num-format shortly and will update this code to use version 0.2.1 as opposed to 0.2.0 once it’s up. Then the Windows CI should pass.

inferno's Windows CI identified a small bug
in num-format 0.2.0. A trait was being implemented
on a unix-only type unconditionally. num-format 0.2.1
fixes this bug; so updating the Cargo.lock should
fix the issue. While I was at it I just ran
`cargo update` in general; so a few other
dependencies also got the minor versions bumped.
@bcmyers
Copy link
Contributor Author

bcmyers commented Feb 7, 2019

Alight ... So that wasn't my only Windows issue. libc::lconv is not available on Windows; so let me figure out the best way to update num-format to work on windows and then update this PR once that's finished. Will come back to you.

@ErichDonGubler
Copy link

Pinging @bcmyers: any update?

@bcmyers
Copy link
Contributor Author

bcmyers commented Feb 14, 2019

Need a couple more days (Friday maybe?), but have been actively working on 0.3.0 of num-format. The changes needed for a new version of num-format have nothing to do with the part that would be used in this code (they relate to asking linux, windows, bsd.. for locale information, which is not needed here), but nevertheless I want to get that right before putting up another version on crates.io. Once it's up, making this PR work should be trivial.

@codecov-io
Copy link

codecov-io commented Feb 19, 2019

Codecov Report

Merging #38 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #38   +/-   ##
=======================================
  Coverage   81.32%   81.32%           
=======================================
  Files           9        9           
  Lines         889      889           
=======================================
  Hits          723      723           
  Misses        166      166
Impacted Files Coverage Δ
src/flamegraph/mod.rs 81.92% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b11558...a114ffe. Read the comment docs.

@bcmyers
Copy link
Contributor Author

bcmyers commented Feb 19, 2019

I just published a new version of num-format on crates.io, which fixes the issues I was having on Windows. This PR now incorporates those changes. Let me know if you have any questions / issues.

@jonhoo
Copy link
Owner

jonhoo commented Feb 19, 2019

That's an awful lot of new dependencies just for number formatting :/ This pulls in hashbrown, regex, and termcolor to name a few that struck me as particularly odd. Any way we can avoid those?

@bcmyers
Copy link
Contributor Author

bcmyers commented Feb 19, 2019

Yah, the dependency explosion is due to stuff needed to support asking your OS for its locale (which is not needed here). It's not as bad as it looks since only Windows is the problem (and when you build on Unix the Windows dependencies don't come in). That said, what I need to do is put all the OS stuff behind a feature flag or something; so if you don't need that functionality you don't bring in a bunch of unneeded dependencies. That would get rid of all these dependencies as it relates to inferno. Let me take a crack at that and get back to you. This change should be much shorter.

Issue: bcmyers/num-format#14

Version 0.4.0 of num-format hides functionality that
requires a ton of dependencies behind a feature flag
so that inferno, which doesn't use that functionality,
doesn't have to suffer the dependencies.
@bcmyers
Copy link
Contributor Author

bcmyers commented Feb 20, 2019

Dependencies cut down to just arrayvec and itoa.

@jonhoo jonhoo merged commit 58a2730 into jonhoo:master Feb 20, 2019
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.

None yet

4 participants