Skip to content

Size optimize int formatting#125606

Merged
bors merged 1 commit into
rust-lang:masterfrom
diondokter:opt-size-int-fmt
Jun 7, 2024
Merged

Size optimize int formatting#125606
bors merged 1 commit into
rust-lang:masterfrom
diondokter:opt-size-int-fmt

Conversation

@diondokter

Copy link
Copy Markdown
Member

Let's use the new feature flag!

This uses a simpler algorithm to format integers.
It is slower, but also smaller.
It also saves having to import the 200 byte rodata lookup table.

In a test of mine this saves ~300 bytes total of a cortex-m binary that does integer formatting.
For a 16KB device, that's almost 2%.

Note though that for opt-level 3 the text size actually grows by 116 bytes.
Still a win in total. I'm not sure why the generated code is bigger than the more fancy algo. Maybe the smaller algo lends itself more to inlining and duplicating?

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants