Skip to content

Conversation

lorentey
Copy link
Member

This makes _CocoaSet.Index and _CocoaDictionary.Index fully resilient for now, allowing us to replace/fix its internals at any point in the future.

@lorentey
Copy link
Member Author

@swift-ci please smoke benchmark

@lorentey
Copy link
Member Author

@swift-ci please smoke test

@lorentey
Copy link
Member Author

cc @airspeedswift What do you think? This leaves the door open for a Cocoa indexing overhaul.

@swift-ci

This comment has been minimized.

@lorentey
Copy link
Member Author

Hm, this seems a bit excessive.

@lorentey
Copy link
Member Author

lorentey commented Sep 28, 2018

Gosh; Dictionary.Keys and .Values use IndexingIterator. That won't do at all.

@lorentey
Copy link
Member Author

I think #19576 (for swapAt) and #19602 (for Histogram et al) will cut down these performance regressions.

@lorentey
Copy link
Member Author

@swift-ci please smoke test

@lorentey
Copy link
Member Author

@swift-ci please smoke benchmark

@swift-ci
Copy link
Contributor

Build comment file:

Build failed before running benchmark.


@lorentey
Copy link
Member Author

@swift-ci please smoke test

@lorentey
Copy link
Member Author

@swift-ci please smoke benchmark

@swift-ci

This comment has been minimized.

@lorentey
Copy link
Member Author

lorentey commented Sep 28, 2018

Hm, I'll have to make the Cocoa Index storage representation @_fixed_layout to reduce these regressions.

I'll do that by converting it to a CoW type, which I was planning to do anyway.

@lorentey lorentey force-pushed the opaque-cocoa-indices branch from b99ff62 to fb0cf68 Compare September 28, 2018 16:35
@lorentey
Copy link
Member Author

@swift-ci please smoke benchmark

@lorentey
Copy link
Member Author

@swift-ci please smoke test

@lorentey
Copy link
Member Author

Oops, I forgot to apply these changes to Dictionary; I'm afraid these next benchmarks will still disappoint

This enables making the struct @_fixed_layout, which should win us back some of the performance lost by hiding Cocoa indexing internals.
@swift-ci

This comment has been minimized.

@lorentey lorentey force-pushed the opaque-cocoa-indices branch from fb0cf68 to 900c930 Compare September 28, 2018 17:28
@lorentey
Copy link
Member Author

@swift-ci please smoke benchmark

@lorentey
Copy link
Member Author

@swift-ci please smoke test

@lorentey
Copy link
Member Author

Sigh

@swift-ci please smoke test linux platform

@lorentey
Copy link
Member Author

Okay, this should do the trick. (He said, with a naive look on his face.)

@swift-ci
Copy link
Contributor

Build comment file:

Performance: -O

TEST OLD NEW DELTA RATIO
Improvement
CStringLongAscii 3552 3299 -7.1% 1.08x (?)

Code size: -O

TEST OLD NEW DELTA RATIO
Regression
DictOfArraysToArrayOfDicts.o 34702 35142 +1.3% 0.99x
Improvement
DictionarySwap.o 32475 31406 -3.3% 1.03x
RGBHistogram.o 28401 27517 -3.1% 1.03x

Performance: -Osize

TEST OLD NEW DELTA RATIO
Improvement
CStringLongAscii 3543 3288 -7.2% 1.08x
FloatingPointPrinting_Float_description_small 5673 5282 -6.9% 1.07x

Code size: -Osize

TEST OLD NEW DELTA RATIO
Improvement
DictionarySwap.o 28555 27331 -4.3% 1.04x
RGBHistogram.o 24881 24077 -3.2% 1.03x

Performance: -Onone

TEST OLD NEW DELTA RATIO
Regression
CharIteration_utf16_unicodeScalars_Backwards 248178 304188 +22.6% 0.82x
ArrayOfPOD 758 846 +11.6% 0.90x (?)
CharIteration_chinese_unicodeScalars_Backwards 225786 247267 +9.5% 0.91x
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

@lorentey
Copy link
Member Author

Oh hi! I'm just sitting over here, improving benchmarks by making things non-inlinable.

(This probably just means we lack indexing benchmarks for bridged sets/dictionaries.)

@lorentey lorentey merged commit bb36ddf into swiftlang:master Sep 28, 2018
@lorentey lorentey deleted the opaque-cocoa-indices branch September 28, 2018 18:53
@@ -1897,7 +1897,7 @@ extension Dictionary.Index: Comparable {
}

extension Dictionary.Index: Hashable {
@inlinable
@_effects(readonly) // FIXME(cocoa-index): Make inlinable
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this correct? It writes to the hasher, after all.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, oops, good catch!

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