Skip to content

[benchmark][SR-3106] Add benchmarks with 4 different Observers #5583

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
Nov 2, 2016

Conversation

lorentey
Copy link
Member

@lorentey lorentey commented Nov 1, 2016

This pull request adds four benchmarks to Swift's benchmark suite that highlight optimization opportunities in the implementation of partially applied method invocations and escaping closures.

It augments (but does not resolve) SR-3106, in which I complain about their slowness relative to hand-written forwarding structs.

Here is a typical run on my system: (2012 15" rMBP):

  # TEST                      SAMPLES MIN(μs) MAX(μs) MEAN(μs) SD(μs) MEDIAN(μs) MAX_RSS(B)
 97 ObserverClosure                10    2547    2752     2599      0       2599  308317798
 98 ObserverForwarderStruct        10    1345    1972     1480      0       1480  614535987
 99 ObserverPartiallyAppliedMethod 10    3953    4194     4049      0       4049  267670733
100 ObserverUnappliedMethod        10    2990    3482     3093      0       3093  338796544

I'd have expected partially applied method invocations to be just as fast as hand-written method forwarding structs stored inside protocol existentials. In fact, in these benchmarks, they are almost three times slower than that, and two times slower than plain closures.

…rent ways

These benchmarks highlight optimization opportunities in the implementation
of partially applied methods and escaping closures.

  # TEST                      SAMPLES MIN(μs) MAX(μs) MEAN(μs) SD(μs) MEDIAN(μs) MAX_RSS(B)
 97 ObserverClosure                10    2547    2752     2599      0       2599  308317798
 98 ObserverForwarderStruct        10    1345    1972     1480      0       1480  614535987
 99 ObserverPartiallyAppliedMethod 10    3953    4194     4049      0       4049  267670733
100 ObserverUnappliedMethod        10    2990    3482     3093      0       3093  338796544
@gottesmm
Copy link
Contributor

gottesmm commented Nov 1, 2016

@swift-ci Please smoke test and merge

@gottesmm
Copy link
Contributor

gottesmm commented Nov 2, 2016

@swift-ci Please smoke test linux platform

@gottesmm
Copy link
Contributor

gottesmm commented Nov 2, 2016

Not sure why the timeout occurred when compiling xctest.

@gottesmm gottesmm merged commit 1f931f9 into swiftlang:master Nov 2, 2016
@gottesmm
Copy link
Contributor

gottesmm commented Nov 2, 2016

Thanks!

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