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

Add AnyValue #113

Merged
merged 2 commits into from
Aug 28, 2020
Merged

Add AnyValue #113

merged 2 commits into from
Aug 28, 2020

Conversation

dabrahams
Copy link
Collaborator

@dabrahams dabrahams commented Aug 26, 2020

OMG this was so hard to get right, you don't even know.

Note: see commit messages for progression of results.

swift run -c release -Xswiftc -cross-module-optimization Benchmarks --warmup-iterations 2 --filter AnyValue

name                                             time            std        iterations warmup      
---------------------------------------------------------------------------------------------------
AnyValue.erased [Int] sum                             6695608 ns ±   3.24 %        210  15740437 ns
AnyValue.erased [Int] swapHalves                      1591548 ns ±   6.03 %        858   3213536 ns
AnyValue.erased [Int]x2 sum                       3812041.500 ns ±   4.37 %        362   7813602 ns
AnyValue.erased [Int]x2 swapHalves                5092725.500 ns ±   4.47 %        266  10145487 ns
AnyValue.erased [Int]x4 sum                           2194474 ns ±   5.67 %        621   4470787 ns
AnyValue.erased [Int]x4 swapHalves                    4961560 ns ±   4.33 %        277  10111853 ns

NaiveAnyBased_AnyValue.erased [Int] sum          68659456.500 ns ±   3.19 %         20 136630376 ns
NaiveAnyBased_AnyValue.erased [Int] swapHalves   26975835.500 ns ±   2.23 %         52  55485238 ns
NaiveAnyBased_AnyValue.erased [Int]x2 sum        34115200.500 ns ±   7.83 %         42  68211571 ns
NaiveAnyBased_AnyValue.erased [Int]x2 swapHalves     61322458 ns ±   1.30 %         22 140975636 ns
NaiveAnyBased_AnyValue.erased [Int]x4 sum         4852811.500 ns ±   3.87 %        290   9933364 ns
NaiveAnyBased_AnyValue.erased [Int]x4 swapHalves 13151125.500 ns ±   4.09 %        104  27471499 ns

ClassBoxBased_AnyValue.erased [Int] sum              13703008 ns ±   7.85 %        101  27719254 ns
ClassBoxBased_AnyValue.erased [Int] swapHalves        2559842 ns ±   4.72 %        532   5151679 ns
ClassBoxBased_AnyValue.erased [Int]x2 sum             2732989 ns ±   4.55 %        508   5658913 ns
ClassBoxBased_AnyValue.erased [Int]x2 swapHalves      5792227 ns ±   3.56 %        242  11931203 ns
ClassBoxBased_AnyValue.erased [Int]x4 sum         2489451.500 ns ±   4.67 %        564   5249983 ns
ClassBoxBased_AnyValue.erased [Int]x4 swapHalves      4859068 ns ±   4.80 %        285   9724080 ns

Copy link
Owner

@saeta saeta left a comment

Choose a reason for hiding this comment

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

Couple comments.

Sources/PenguinStructures/AnyValue.swift Outdated Show resolved Hide resolved
Sources/PenguinStructures/AnyValue.swift Show resolved Hide resolved
Sources/PenguinStructures/AnyValue.swift Outdated Show resolved Hide resolved
Sources/PenguinStructures/AnyValue.swift Outdated Show resolved Hide resolved
Sources/PenguinStructures/AnyValue.swift Outdated Show resolved Hide resolved
Tests/PenguinStructuresTests/AnyValueTests.swift Outdated Show resolved Hide resolved
Tests/PenguinStructuresTests/AnyValueTests.swift Outdated Show resolved Hide resolved
Tests/PenguinStructuresTests/AnyValueTests.swift Outdated Show resolved Hide resolved
Tests/PenguinStructuresTests/AnyValueTests.swift Outdated Show resolved Hide resolved
@dabrahams dabrahams force-pushed the anyvalue branch 3 times, most recently from 8d758cc to 718bcb0 Compare August 28, 2020 06:10
Copy link
Owner

@saeta saeta left a comment

Choose a reason for hiding this comment

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

Eagerly approving to unblock, but please do look at some of the suggested changes (because I'm not sure your benchmarks are testing what their descriptions seem to imply). Additionally, if you could include a copy-pasta of the console output of running the benchmarks in the PR discussion thread, that would be much appreciated. :-)

Thanks!
-Brennan

Sources/Benchmarks/AnyValueBenchmarks.swift Show resolved Hide resolved
Sources/Benchmarks/AnyValueBenchmarks.swift Outdated Show resolved Hide resolved
Sources/Benchmarks/AnyValueBenchmarks.swift Show resolved Hide resolved
Sources/Benchmarks/AnyValueBenchmarks.swift Outdated Show resolved Hide resolved
Sources/Benchmarks/AnyValueBenchmarks.swift Outdated Show resolved Hide resolved
Sources/Benchmarks/main.swift Show resolved Hide resolved
Sources/Benchmarks/ConcurrencyPlatform.swift Show resolved Hide resolved
Copy link
Owner

@saeta saeta left a comment

Choose a reason for hiding this comment

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

Marking as approved for merge. Thanks @dabrahams !

Dave Abrahams added 2 commits August 28, 2020 15:09
Brennan will resolve the duplication and perform module dependency inversion as necessary.
swift run -c release -Xswiftc -cross-module-optimization Benchmarks --warmup-iterations 2 --filter AnyValue

name                                             time            std        iterations warmup
---------------------------------------------------------------------------------------------------
AnyValue.erased [Int] sum                             6695608 ns ±   3.24 %        210  15740437 ns
AnyValue.erased [Int] swapHalves                      1591548 ns ±   6.03 %        858   3213536 ns
AnyValue.erased [Int]x2 sum                       3812041.500 ns ±   4.37 %        362   7813602 ns
AnyValue.erased [Int]x2 swapHalves                5092725.500 ns ±   4.47 %        266  10145487 ns
AnyValue.erased [Int]x4 sum                           2194474 ns ±   5.67 %        621   4470787 ns
AnyValue.erased [Int]x4 swapHalves                    4961560 ns ±   4.33 %        277  10111853 ns

NaiveAnyBased_AnyValue.erased [Int] sum          68659456.500 ns ±   3.19 %         20 136630376 ns
NaiveAnyBased_AnyValue.erased [Int] swapHalves   26975835.500 ns ±   2.23 %         52  55485238 ns
NaiveAnyBased_AnyValue.erased [Int]x2 sum        34115200.500 ns ±   7.83 %         42  68211571 ns
NaiveAnyBased_AnyValue.erased [Int]x2 swapHalves     61322458 ns ±   1.30 %         22 140975636 ns
NaiveAnyBased_AnyValue.erased [Int]x4 sum         4852811.500 ns ±   3.87 %        290   9933364 ns
NaiveAnyBased_AnyValue.erased [Int]x4 swapHalves 13151125.500 ns ±   4.09 %        104  27471499 ns

ClassBoxBased_AnyValue.erased [Int] sum              13703008 ns ±   7.85 %        101  27719254 ns
ClassBoxBased_AnyValue.erased [Int] swapHalves        2559842 ns ±   4.72 %        532   5151679 ns
ClassBoxBased_AnyValue.erased [Int]x2 sum             2732989 ns ±   4.55 %        508   5658913 ns
ClassBoxBased_AnyValue.erased [Int]x2 swapHalves      5792227 ns ±   3.56 %        242  11931203 ns
ClassBoxBased_AnyValue.erased [Int]x4 sum         2489451.500 ns ±   4.67 %        564   5249983 ns
ClassBoxBased_AnyValue.erased [Int]x4 swapHalves      4859068 ns ±   4.80 %        285   9724080 ns
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.

None yet

2 participants