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

[stdlib] Implement SE-0233 AdditiveArithmetic #20422

Merged
merged 9 commits into from
Nov 10, 2018

Conversation

rxwei
Copy link
Contributor

@rxwei rxwei commented Nov 8, 2018

@rxwei
Copy link
Contributor Author

rxwei commented Nov 8, 2018

@swift-ci please smoke test

@stephentyrone
Copy link
Contributor

@swift-ci please test

@stephentyrone
Copy link
Contributor

@swift-ci please test source compatibility

@swift-ci
Copy link
Contributor

swift-ci commented Nov 8, 2018

Build failed
Swift Test OS X Platform
Git Sha - 44c2f77

@swift-ci
Copy link
Contributor

swift-ci commented Nov 8, 2018

Build failed
Swift Test Linux Platform
Git Sha - 44c2f77

//===----------------------------------------------------------------------===//

public protocol AdditiveArithmetic : Equatable {
/// The zero value.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we expand this comment with a note that zero is the name of the additive identity? Something like
/// zero is the identity element for addition; for any value x,x + .zero == x and .zero + x == x.

Copy link
Contributor Author

@rxwei rxwei Nov 8, 2018

Choose a reason for hiding this comment

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

Done. There's still no doc comment on the protocol itself, but writing good doc comments would take time :) I added TODO's for that.

@stephentyrone
Copy link
Contributor

stephentyrone commented Nov 8, 2018

LGTM aside from minor documentation request. If tests pass, I'm fine with merging as is and adjusting documentation in follow-on patch.

@stephentyrone
Copy link
Contributor

@swift-ci please test performance

@rxwei
Copy link
Contributor Author

rxwei commented Nov 8, 2018

@swift-ci please smoke test

@rxwei
Copy link
Contributor Author

rxwei commented Nov 8, 2018

@swift-ci please test performance

@rxwei
Copy link
Contributor Author

rxwei commented Nov 8, 2018

@swift-ci please test source compatibility

@rxwei rxwei force-pushed the additive-arithmetic branch from 4bdd2fe to b788e55 Compare November 8, 2018 18:42
@rxwei
Copy link
Contributor Author

rxwei commented Nov 8, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Nov 8, 2018

Build failed
Swift Test OS X Platform
Git Sha - bc8b623

@rxwei
Copy link
Contributor Author

rxwei commented Nov 8, 2018

@swift-ci please test os x platform

@swift-ci
Copy link
Contributor

swift-ci commented Nov 8, 2018

Build failed
Swift Test Linux Platform
Git Sha - b788e55

@rxwei
Copy link
Contributor Author

rxwei commented Nov 8, 2018

Not sure why CI says "Build timed out (after 60 minutes)". @shahmishal

/// example:
///
/// 1 + 2 // 3
/// -10 + 15 // 5
Copy link
Collaborator

Choose a reason for hiding this comment

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

Examples involving the unary negative operator should probably be removed from the documentation for this protocol.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but it was originally on Numeric, and Numeric did not have - either. I'd like for this PR to focus on the implementation (to unblock @stephentyrone's SIMD PR, for example), and write a separate patch to refine documentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right. @xwu, can you open a SR bug for this (since we would want to consider it on Numeric anyway) and CC me and @natecook1000?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@shahmishal
Copy link
Member

Not sure why CI says "Build timed out (after 60 minutes)". @shahmishal

We are looking into why LLDB test suite.

@rxwei
Copy link
Contributor Author

rxwei commented Nov 9, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Nov 9, 2018

Build failed
Swift Test OS X Platform
Git Sha - b788e55

@swift-ci
Copy link
Contributor

swift-ci commented Nov 9, 2018

Build failed
Swift Test Linux Platform
Git Sha - b788e55

@airspeedswift
Copy link
Member

@swift-ci please benchmark

@airspeedswift
Copy link
Member

@swift-ci please test compiler performance

@swift-ci
Copy link
Contributor

swift-ci commented Nov 9, 2018

Build comment file:


@airspeedswift
Copy link
Member

oh, duh, can't run the benchmarks until the conflicts are resolved, sorry

@rxwei
Copy link
Contributor Author

rxwei commented Nov 9, 2018

@swift-ci please benchmark

1 similar comment
@airspeedswift
Copy link
Member

@swift-ci please benchmark

@airspeedswift
Copy link
Member

@swift-ci please test compiler performance

@swift-ci
Copy link
Contributor

swift-ci commented Nov 9, 2018

Build comment file:


@airspeedswift
Copy link
Member

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Nov 9, 2018

Build failed
Swift Test Linux Platform
Git Sha - da50193

@swift-ci
Copy link
Contributor

swift-ci commented Nov 9, 2018

Build failed
Swift Test OS X Platform
Git Sha - da50193

@swift-ci
Copy link
Contributor

swift-ci commented Nov 9, 2018

Build comment file:

Performance: -O

TEST OLD NEW DELTA RATIO
Improvement
StringEqualPointerComparison 657 571 -13.1% 1.15x
IterateData 1609 1399 -13.1% 1.15x

Code size: -O

TEST OLD NEW DELTA RATIO
Regression
BinaryFloatingPointConversionFromBinaryInteger.o 11305 11621 +2.8% 0.97x

Performance: -Osize

TEST OLD NEW DELTA RATIO
Improvement
IterateData 1541 1365 -11.4% 1.13x
StringEqualPointerComparison 628 571 -9.1% 1.10x

Code size: -Osize

TEST OLD NEW DELTA RATIO
Regression
BinaryFloatingPointConversionFromBinaryInteger.o 11209 11525 +2.8% 0.97x

Performance: -Onone

TEST OLD NEW DELTA RATIO
Improvement
ArrayOfPOD 858 777 -9.4% 1.10x
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
--------------

@rxwei
Copy link
Contributor Author

rxwei commented Nov 9, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Nov 9, 2018

Build failed
Swift Test Linux Platform
Git Sha - 4e2147e

@swift-ci
Copy link
Contributor

swift-ci commented Nov 9, 2018

Build failed
Swift Test OS X Platform
Git Sha - 4e2147e

@rxwei
Copy link
Contributor Author

rxwei commented Nov 9, 2018

@swift-ci please smoke test

@rxwei
Copy link
Contributor Author

rxwei commented Nov 9, 2018

@swift-ci please smoke test os x

@rxwei
Copy link
Contributor Author

rxwei commented Nov 10, 2018

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit 94dc4a6 into swiftlang:master Nov 10, 2018
@rxwei rxwei deleted the additive-arithmetic branch November 10, 2018 14:10
@jrose-apple
Copy link
Contributor

jrose-apple commented Nov 13, 2018

This broke the source compat suite:

/Users/buildnode/jenkins/workspace-private/swift-PR-source-compat-suite-debug/project_cache/Tagged/Sources/Tagged/Tagged.swift:110:1: error: conditional conformance of type 'Tagged<Tag, RawValue>' to protocol 'Numeric' does not imply conformance to inherited protocol 'AdditiveArithmetic'
extension Tagged: Numeric where RawValue: Numeric {
^

…hm. That's a valid error.

@slavapestov
Copy link
Contributor

slavapestov commented Nov 13, 2018

Can we at least update the proposal to explain the migration path?

The proposed change is fully source-compatible.

This is clearly not true, because conditional conformances don't imply conformance to refined protocols.

It's not even clear to me how one would go about implementing this conformance in a way that works with both 4.2 and 5.0.

@rxwei
Copy link
Contributor Author

rxwei commented Nov 13, 2018

This is clearly not true, because conditional conformances don't imply conformance to refined protocols.

Thanks for the tip. It was not clear to me. Given that it passed the core team review, it wasn't clear to other folks either. Could you please suggest a way to fix this? If there's no possible fix, I'll be happy to explain the migration path and update the compatibility suite.

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.

8 participants