Skip to content

Native implementation of -lengthOfBytesUsingEncoding, plus handling ASCII-subset MacRoman in a few places #81791

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

Merged
merged 15 commits into from
Jun 27, 2025

Conversation

Catfish-Man
Copy link
Contributor

@Catfish-Man Catfish-Man commented May 28, 2025

Fixes rdar://154341146 (Speed up lengthOfBytes(using:) for URL

@Catfish-Man Catfish-Man self-assigned this May 28, 2025
@Catfish-Man
Copy link
Contributor Author

@swift-ci please test

@Catfish-Man
Copy link
Contributor Author

@swift-ci please Apple Silicon benchmark

…ngthOfBytesUsingEncoding, plus handle ASCII-subset MacRoman in a few places
@Catfish-Man
Copy link
Contributor Author

@swift-ci please Apple Silicon benchmark

@Catfish-Man
Copy link
Contributor Author

@swift-ci please test

@Catfish-Man
Copy link
Contributor Author

@swift-ci please test

@Catfish-Man
Copy link
Contributor Author

@swift-ci please test

@Catfish-Man
Copy link
Contributor Author

@swift-ci please Apple Silicon benchmark

@Catfish-Man
Copy link
Contributor Author

@swift-ci please benchmark

@Catfish-Man
Copy link
Contributor Author

@swift-ci please Apple Silicon benchmark

@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test

@Catfish-Man
Copy link
Contributor Author

------- Performance (arm64): -O -------
------- Code size: -O -------

Looks like we'll need benchmark coverage for these

@Catfish-Man
Copy link
Contributor Author

@swift-ci please Apple Silicon benchmark

@Catfish-Man
Copy link
Contributor Author

@swift-ci please benchmark

@Catfish-Man
Copy link
Contributor Author

@swift-ci please test

@Catfish-Man
Copy link
Contributor Author

Catfish-Man commented Jun 14, 2025

Eyeballing the benchmarks it looks like it's a >100x speedup for lengthOfBytes(using:) and a ~1.3x speedup for maxLengthOfBytes(using:).

Will wait for the benchmarks to land so I can run the comparison properly, but I'm considering removing the maxLength bit for simplicity since it's not a huge win.

@Catfish-Man Catfish-Man changed the title Native implementations of -maximumLengthOfBytesUsingEncoding: and -lengthOfBytesUsingEncoding, plus handle ASCII-subset MacRoman in a few places Native implementation of -lengthOfBytesUsingEncoding, plus handling ASCII-subset MacRoman in a few places Jun 24, 2025
@Catfish-Man
Copy link
Contributor Author

@swift-ci please test

@Catfish-Man
Copy link
Contributor Author

@swift-ci Please smoke test Linux platform

@Catfish-Man Catfish-Man marked this pull request as ready for review June 25, 2025 20:49
@Catfish-Man Catfish-Man requested review from a team and eeckstein as code owners June 25, 2025 20:49
@@ -914,3 +942,40 @@ public func run_RealNSArrayMutableCopyObjectAtIndex(_ n: Int) {
#endif
}

@inline(__always)
fileprivate func run_BridgedNSStringLength(_ asciiBase: Bool, _ enc: UInt, _ n: Int) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the same benchmarks as the PR adding benchmarks, so once that merges this part of the diff will go away

@Catfish-Man
Copy link
Contributor Author

@swift-ci please test

@Catfish-Man
Copy link
Contributor Author

@swift-ci please test

@Catfish-Man
Copy link
Contributor Author

swiftlang/swift-driver#1940
@swift-ci please test macOS

@Catfish-Man
Copy link
Contributor Author

Please test with following PR:
swiftlang/swift-driver#1940
@swift-ci please test macOS platform

@Catfish-Man
Copy link
Contributor Author

Please test with following PR:
swiftlang/swift-driver#1940
@swift-ci please test Linux platform

@Catfish-Man
Copy link
Contributor Author

Please test with following PR:
swiftlang/swift-driver#1940
@swift-ci please test Windows platform

@Catfish-Man
Copy link
Contributor Author

ok hopefully that'll sort things out. Bot was being finicky about the triggers before

Copy link

@jrflat jrflat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM post-LLP64 fun :)

@Catfish-Man Catfish-Man enabled auto-merge (squash) June 26, 2025 00:09
@Catfish-Man
Copy link
Contributor Author

@swift-ci please test

@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test macOS platform

@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test

@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test

1 similar comment
@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test

@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test macOS platform

@Catfish-Man Catfish-Man merged commit 1a56da6 into main Jun 27, 2025
3 checks passed
@Catfish-Man Catfish-Man deleted the a-lengthy-task branch June 27, 2025 20:48
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