-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Speed up string to integer conversion too #87249
Copy link
Copy link
Open
Labels
A-strArea: str and StringArea: str and StringC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchE-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
Metadata
Metadata
Assignees
Labels
A-strArea: str and StringArea: str and StringC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchE-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Now that #86761 is merged, it might be worth looking in other places too where potentially faster conversion algorithms can be used. This page has quite a lot of them:
https://johnnylee-sde.github.io/
One of them is this string to integer conversion algorithm: https://johnnylee-sde.github.io/Fast-numeric-string-to-int/
This algorithm is also used and mention in #86761 under Digit Parsing Improvements. It seems this approach allows parsing 8 digits at once instead of parsing one digit at a time which is what the algorithm in
corecurrently does for integer to string conversion:https://doc.rust-lang.org/src/core/num/mod.rs.html#843
Perhaps this new algorithm can then be reused in some form or another in the float parsing algorithm for more code reusage.
Here is a proof of concept program making use of the final algorithm at the bottom of the Fast numeric string to int article: