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

[SR-7556] [String] Improve Int(_:String, radix:Int) size and performance #50098

Open
milseman mannequin opened this issue Apr 27, 2018 · 1 comment
Open

[SR-7556] [String] Improve Int(_:String, radix:Int) size and performance #50098

milseman mannequin opened this issue Apr 27, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@milseman
Copy link
Mannequin

milseman mannequin commented Apr 27, 2018

Previous ID SR-7556
Radar None
Original Reporter @milseman
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: 6c726c2bcb53150bc4c96ab17a6f1588

relates to:

  • SR-9438 Rewrite _uint64ToString etc to Swift

Issue Description:

Constructing an Int from a String eventually involves calling parseASCII, which is slow and bloated if not properly specialized. A serious of unfortunate events played out over time where this function was overly generic and so was marked inline(__always) to be fast, then it was discovered this function was about 20KB large and the callers were all marked with @inline(never) and various @semantics to disable specialization for size (and perhaps compilation time). The end result was something bloated, slow, and yet is still emitted into the user module, increasing code size.

However, a simpler and more efficient implementation should be easily implementable. At the very least, it could hard code fast-paths for radices of 10 or 16, and fall back to slow paths for the rest.

@xwu
Copy link
Collaborator

xwu commented Apr 3, 2021

A re-written implementation that is less overly generic, thereby permitting inlining without seriously increasing code size, has been merged in PR #36623. Performance on microbenchmarks is improved up to 50%.

Further optimizations for bit width ≤ 64 and/or for common bases may be possible.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

1 participant