Skip to content

Conversation

@finnbear
Copy link
Contributor

This makes decoding Decimal in bitcode 10X faster.

It works since bitcode checks the range of limited-range integers (like scale) up front, all at once, using vector instructions, and then uses unreachable_unchecked right before calling Decimal::from_parts to communicate that fact to rustc. This only works if Decimal::from_parts is inlinable.

@Tony-Samuels Tony-Samuels merged commit 3f1973e into paupino:master Aug 13, 2025
15 checks passed
@Tony-Samuels
Copy link
Collaborator

Tony-Samuels commented Aug 13, 2025

I'm surprised the compiler doesn't just do this TBH, the inline attribute is only a suggestion.

If you'd like to see this in the next v1 release, please raise the same MR against the v1 branch. master is currently working towards an eventual v2.

@finnbear
Copy link
Contributor Author

finnbear commented Aug 13, 2025

I'm surprised the compiler doesn't just do this TBH, the inline attribute is only a suggestion.

AFAIK, the Rust compiler doesn't consider inlining non-generic functions across crate boundaries unless using LTO (link-time optimization), which increases compile times and isn't on by default.

Arguably, all simple functions in rust_decimal should be #[inline].

If you'd like to see this in the next v1 release, please raise the same MR against the v1 branch.

Good to know, I'll keep that in mind!

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.

2 participants