rust-lang / rust-lang/rust

Is `core::fmt::float` poorly optimized on thumbv7em-none-eabihf or is the binary analysis tooling incorrect?

Open
#118,337 19 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-codegen C-optimization I-heavy O-Arm S-needs-repro T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Adding formatting output (write) for float numbers for Cortex M4F increase binary size twice: from 39396 bytes to 66468 bytes. (optimisation flag: z)
The main high weigh functions are (provided by cargo bloat):

2.4%  22.7% 11.2KiB             std core::fmt::float::float_to_decimal_common_shortest
1.9%  17.8%  8.8KiB             std core::fmt::float::float_to_decimal_common_exact
0.9%   8.6%  4.2KiB             std core::num::dec2flt::<impl core::str::traits::FromStr for f32>::from_str
0.4%   3.8%  1.9KiB             std core::fmt::Formatter::pad

and others

For desktop application (Apple M2Pro chip, native build) with same functions size lower than few kilobytes:

 0.1%   0.3%     732B         std core::fmt::float::float_to_decimal_common_exact
 0.1%   0.3%     624B         std core::fmt::float::float_to_decimal_common_shortest
  0.3%   0.6%   1.3KiB         std core::num::dec2flt::<impl core::str::traits::FromStr for f32>::from_str
 0.2%   0.4%     980B         std core::fmt::Formatter::pad

Which reason of overweigh these functions for Cortex-M4F?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported size difference for thumbv7em-none-eabihf with optimization level z, comparing cargo bloat output for the Cortex-M4F and desktop builds. Investigate the listed core::fmt::float and core::num::dec2flt functions, then determine whether the excess size is generated code or an analysis-tooling issue and document the cause.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.