Skip to content

SR-10555 foreignCopyUTF8 should do bulk access #24289

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 1 commit into from
Apr 30, 2019

Conversation

Catfish-Man
Copy link
Contributor

@Catfish-Man Catfish-Man commented Apr 25, 2019

Fixes https://bugs.swift.org/browse/SR-10555 and rdar://50220164

@Catfish-Man Catfish-Man self-assigned this Apr 25, 2019
@Catfish-Man Catfish-Man force-pushed the bulk-discount branch 2 times, most recently from b67972b to c90534e Compare April 25, 2019 21:09
@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke benchmark

@Catfish-Man Catfish-Man requested a review from milseman April 25, 2019 21:18
Copy link
Member

@milseman milseman left a comment

Choose a reason for hiding this comment

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

Want to make sure we trigger the precondition failure. Might be worth adding a test case to StringTraps.swift for this.

@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke benchmark

@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test

@Catfish-Man
Copy link
Contributor Author

Oops, forgot to make that conditional for ObjC

Copy link
Member

@milseman milseman left a comment

Choose a reason for hiding this comment

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

LGTM, let's see if it's covered by a benchmark

@milseman
Copy link
Member

@swift-ci
Copy link
Contributor

Performance: -O

TEST OLD NEW DELTA RATIO
Regression
EqualSubstringSubstring 34 37 +8.8% 0.92x (?)
EqualStringSubstring 34 37 +8.8% 0.92x (?)
EqualSubstringSubstringGenericEquatable 34 37 +8.8% 0.92x (?)
LessSubstringSubstring 35 38 +8.6% 0.92x (?)

Performance: -Osize

TEST OLD NEW DELTA RATIO
Regression
DataReplaceLarge 18200 19800 +8.8% 0.92x (?)
LessSubstringSubstring 35 38 +8.6% 0.92x (?)
EqualSubstringSubstringGenericEquatable 35 38 +8.6% 0.92x (?)
EqualSubstringString 35 38 +8.6% 0.92x (?)
LessSubstringSubstringGenericComparable 35 38 +8.6% 0.92x
How to read the data The tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.

If you see any unexpected regressions, you should consider fixing the
regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false
alarms. Unexpected regressions which are marked with '(?)' are probably noise.
If you see regressions which you cannot explain you can try to run the
benchmarks again. If regressions still show up, please consult with the
performance team (@eeckstein).

Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 8-Core Intel Xeon E5
  Processor Speed: 3 GHz
  Number of Processors: 1
  Total Number of Cores: 8
  L2 Cache (per Core): 256 KB
  L3 Cache: 25 MB
  Memory: 16 GB

@Catfish-Man
Copy link
Contributor Author

Alas, will have to write some new benchmarks

@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke benchmark

@swift-ci
Copy link
Contributor

Performance: -O

TEST OLD NEW DELTA RATIO
Regression
LessSubstringSubstring 39 43 +10.3% 0.91x (?)
DataReplaceLarge 20400 22400 +9.8% 0.91x (?)
ObjectiveCBridgeStubToNSDate2 1370 1480 +8.0% 0.93x (?)
EqualSubstringSubstring 38 41 +7.9% 0.93x (?)
EqualStringSubstring 38 41 +7.9% 0.93x (?)
EqualSubstringSubstringGenericEquatable 38 41 +7.9% 0.93x (?)
LessSubstringSubstringGenericComparable 39 42 +7.7% 0.93x (?)
Improvement
ObjectiveCBridgeASCIIStringFromFile 171 66 -61.4% 2.59x

Performance: -Osize

TEST OLD NEW DELTA RATIO
Regression
LessSubstringSubstringGenericComparable 39 43 +10.3% 0.91x
EqualSubstringSubstring 38 41 +7.9% 0.93x (?)
EqualSubstringSubstringGenericEquatable 39 42 +7.7% 0.93x (?)
EqualSubstringString 39 42 +7.7% 0.93x (?)
Improvement
ObjectiveCBridgeASCIIStringFromFile 171 66 -61.4% 2.59x

Performance: -Onone

TEST OLD NEW DELTA RATIO
Regression
EqualSubstringSubstringGenericEquatable 44 49 +11.4% 0.90x (?)
Improvement
ObjectiveCBridgeASCIIStringFromFile 171 66 -61.4% 2.59x
How to read the data The tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.

If you see any unexpected regressions, you should consider fixing the
regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false
alarms. Unexpected regressions which are marked with '(?)' are probably noise.
If you see regressions which you cannot explain you can try to run the
benchmarks again. If regressions still show up, please consult with the
performance team (@eeckstein).

Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 12-Core Intel Xeon E5
  Processor Speed: 2.7 GHz
  Number of Processors: 1
  Total Number of Cores: 12
  L2 Cache (per Core): 256 KB
  L3 Cache: 30 MB
  Memory: 64 GB

@Catfish-Man
Copy link
Contributor Author

2.6x win, that’s more like it!

@milseman
Copy link
Member

This seems related:

[ RUN      ] StringUTF8Tests.Contiguous Access
stdout>>> abcd
stdout>>> abcdefghijklmnop
stdout>>> abcdéfghijk
stderr>>> Fatal error: invalid Collection: less than 'count' elements in collection: file /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/swift/stdlib/public/core/ContiguousArrayBuffer.swift, line 643
stderr>>> Current stack trace:
stderr>>> 0    libswiftCore.dylib                 0x0000000109dfb020 _swift_stdlib_reportFatalErrorInFile + 116
stderr>>> 1    libswiftCore.dylib                 0x0000000109d14b80 specialized closure #1 in closure #1 in closure #1 in _fatalErrorMessage(_:_:file:line:flags:) + 304
stderr>>> 2    libswiftCore.dylib                 0x0000000109d14dc0 specialized closure #1 in closure #1 in _fatalErrorMessage(_:_:file:line:flags:) + 110
stderr>>> 3    libswiftCore.dylib                 0x0000000109cd2ff0 specialized closure #1 in _fatalErrorMessage(_:_:file:line:flags:) + 124
stderr>>> 4    libswiftCore.dylib                 0x0000000109cd3420 specialized _fatalErrorMessage(_:_:file:line:flags:) + 643
stderr>>> 5    libswiftCore.dylib                 0x0000000109cda0a0 specialized _copyCollectionToContiguousArray<A>(_:) + 900
stderr>>> 6    libswiftCore.dylib                 0x0000000109bbdf50 _StringGuts._foreignGrow(_:) + 56
stderr>>> 7    libswiftCore.dylib                 0x0000000109bbe170 _StringGuts.prepareForAppendInPlace(otherUTF8Count:) + 1323
stderr>>> 8    libswiftCore.dylib                 0x0000000109bbebf0 _StringGuts.append(_:) + 324
stderr>>> 9    libswiftCore.dylib                 0x0000000109cdb050 specialized _StringGuts.append(_:) + 230
stderr>>> 10   libswiftCore.dylib                 0x0000000109a5d8c0 static String.+= infix(_:_:) + 21
stderr>>> 11   String                             0x00000001090eb250 String.makeNative() + 49
stderr>>> 12   String                             0x00000001090eb3e0 closure #1 in  + 3736
stderr>>> 13   libswiftStdlibUnittest.dylib       0x00000001096fa890 specialized TestSuite._runTest(name:parameter:) + 584
stderr>>> 14   libswiftStdlibUnittest.dylib       0x00000001096b8ef0 _childProcess() + 846
stderr>>> 15   String                             0x00000001090ead30 main + 667
stderr>>> 16   libdyld.dylib                      0x00007fff62cc9ed8 start + 1
stderr>>> CRASHED: SIGILL
the test crashed unexpectedly
[     FAIL ] StringUTF8Tests.Contiguous Access
StringUTF8Tests: Some tests failed, aborting
UXPASS: []
FAIL: ["Contiguous Access"]
SKIP: []
To debug, run:
$ /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Output/StringUTF8.swift.tmp/String --stdlib-unittest-in-process --stdlib-unittest-filter "Contiguous Access"

@Catfish-Man
Copy link
Contributor Author

Catfish-Man commented Apr 28, 2019

Yeah, definitely something wrong around the edges of this. Will figure out what and land it on Monday :)

My guess is that we’re ending up in a situation where CFStringGetBytes reports a different number of “characters” converted than what we calculated with .utf8.count

@Catfish-Man
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - cf78d2499a2c65f6c08947b50057e48f6b4ec7eb

@Catfish-Man
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - cf78d2499a2c65f6c08947b50057e48f6b4ec7eb

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - cf78d2499a2c65f6c08947b50057e48f6b4ec7eb

@Catfish-Man
Copy link
Contributor Author

Linux failure is a known unrelated hang

@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test linux platform

@Catfish-Man
Copy link
Contributor Author

@swift-ci please test linux platform

@Catfish-Man
Copy link
Contributor Author

oops. Guess those both worked >.<

@Catfish-Man Catfish-Man merged commit b6d0362 into swiftlang:master Apr 30, 2019
@milseman
Copy link
Member

What was the bug and why did this fix it? Also, can you test and make sure it gives the same result if the foreign string has unpaired surrogates?

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.

3 participants