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

Assorted Refactorings Part 2 #536

Merged
merged 2 commits into from
Jan 8, 2021
Merged

Conversation

nickhudkins
Copy link
Contributor

This is a continuation of #404, with items that Oleg had indicated as potentially risky due to performance implications as mentioned here: #404 (review)

I'd like to keep the changes around, so I have split this into a separate PR in hopes that we can come up with a plan to validate, or disprove Oleg's concerns.

@nickhudkins nickhudkins changed the title Assorted Refactorings Part #2 Assorted Refactorings Part 2 Dec 10, 2020
@yanns
Copy link
Contributor

yanns commented Dec 11, 2020

Now that we have a module for benchmark, one could write a test for this part and compare before & after the change.

@nickhudkins
Copy link
Contributor Author

nickhudkins commented Dec 31, 2020

Hey! It looks like maybe the reason Oleg had indicated the risk was that he experienced performance sensitivity in this area already.

Master:

Result "sangria.benchmarks.OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete":
33743.582 ±(99.9%) 669.221 ops/s [Average]
(min, avg, max) = (31797.042, 33743.582, 35039.683), stdev = 893.391
CI (99.9%): [33074.362, 34412.803] (assumes normal distribution)

This Branch:

Result "sangria.benchmarks.OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete":
34008.015 ±(99.9%) 255.573 ops/s [Average]
(min, avg, max) = (33177.557, 34008.015, 34704.334), stdev = 341.183
CI (99.9%): [33752.442, 34263.588] (assumes normal distribution)

Happy to let these benchmarks run longer, but after the first pass through (5 forks, 5 iteration warmup, 5 test runs), the results look promising that we're not introducing a performance regression by accepting this PR.

@yanns Happy to leave it up to you if you would like me to run longer benchmarks before accepting this is A.O.K.

@nightscape I actually wonder if your hunch about collection methods being more optimized may play out here in the long run!

@yanns
Copy link
Contributor

yanns commented Dec 31, 2020

From 669.221 ops/s to 255.573 ops/s is quite a performance degradation, right?

@nickhudkins
Copy link
Contributor Author

nickhudkins commented Dec 31, 2020

Maybe I am reading it wrong, but my understanding of this is that it's

33743.582 vs 34008.015 ?

Based on this: https://stackoverflow.com/questions/33604084/understanding-jmh-output,

I believe this says, with 99.9% confidence, the first run can be expected to perform
33743.582 (± 669) ops/sec

The second run:
34008.015 (± 255) ops/sec

@nickhudkins
Copy link
Contributor Author

I'll go ahead and get a full run running in the cloud so I can let it sit

@nickhudkins
Copy link
Contributor Author

nickhudkins commented Jan 6, 2021

Master

Benchmark                                                            (size)     (testCase)  (validatorType)   Mode  Cnt         Score        Error  Units
OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete       2            N/A              Old  thrpt   25     18271.535 ±     59.183  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete       2            N/A              New  thrpt   25     19278.953 ±    108.384  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete      10            N/A              Old  thrpt   25      5598.077 ±     61.633  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete      10            N/A              New  thrpt   25      6255.941 ±     15.719  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete     100            N/A              Old  thrpt   25       158.272 ±      1.055  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete     100            N/A              New  thrpt   25       698.410 ±      2.674  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapFrag              2            N/A              Old  thrpt   25     70177.779 ±    392.781  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapFrag              2            N/A              New  thrpt   25     42535.811 ±    253.822  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapFrag             10            N/A              Old  thrpt   25      2887.106 ±     27.716  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapFrag             10            N/A              New  thrpt   25      9043.742 ±     31.258  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapFrag            100            N/A              Old  thrpt   25         0.383 ±      0.005  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapFrag            100            N/A              New  thrpt   25       918.961 ±      3.304  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapNoFrag            2            N/A              Old  thrpt   25    140646.234 ±   2049.645  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapNoFrag            2            N/A              New  thrpt   25     66804.914 ±    554.233  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapNoFrag           10            N/A              Old  thrpt   25     15182.335 ±    196.118  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapNoFrag           10            N/A              New  thrpt   25     16246.895 ±    153.145  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapNoFrag          100            N/A              Old  thrpt   25        43.990 ±      0.416  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapNoFrag          100            N/A              New  thrpt   25      1615.993 ±      7.979  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapFrag                2            N/A              Old  thrpt   25     35730.005 ±     95.861  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapFrag                2            N/A              New  thrpt   25     38429.985 ±    339.620  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapFrag               10            N/A              Old  thrpt   25      1089.862 ±      6.735  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapFrag               10            N/A              New  thrpt   25      9829.611 ±    128.583  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapFrag              100            N/A              Old  thrpt   25         0.325 ±      0.001  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapFrag              100            N/A              New  thrpt   25       966.048 ±      4.876  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapNoFrag              2            N/A              Old  thrpt   25     83371.705 ±    928.733  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapNoFrag              2            N/A              New  thrpt   25     57001.385 ±    694.699  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapNoFrag             10            N/A              Old  thrpt   25      3995.883 ±     42.895  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapNoFrag             10            N/A              New  thrpt   25     15741.374 ±    182.879  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapNoFrag            100            N/A              Old  thrpt   25         1.612 ±      0.001  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapNoFrag            100            N/A              New  thrpt   25      1590.125 ±     11.210  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkRepeatedFields             2            N/A              Old  thrpt   25    158147.729 ±   2360.497  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkRepeatedFields             2            N/A              New  thrpt   25     74136.357 ±    435.569  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkRepeatedFields            10            N/A              Old  thrpt   25     44564.947 ±    702.821  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkRepeatedFields            10            N/A              New  thrpt   25     35614.600 ±    439.629  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkRepeatedFields           100            N/A              Old  thrpt   25       343.071 ±     77.751  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkRepeatedFields           100            N/A              New  thrpt   25      5227.893 ±     16.484  ops/s
StringUtilBenchmark.benchCurrent                                        N/A    empty input              N/A  thrpt   25   3174505.619 ± 165063.949  ops/s
StringUtilBenchmark.benchCurrent                                        N/A  empty options              N/A  thrpt   25  13509447.021 ±  28013.018  ops/s
StringUtilBenchmark.benchCurrent                                        N/A            abc              N/A  thrpt   25    391470.001 ±   5981.717  ops/s
StringUtilBenchmark.benchCurrent                                        N/A    description              N/A  thrpt   25     59222.403 ±    772.384  ops/s
StringUtilBenchmark.benchCurrent                                        N/A         length              N/A  thrpt   25      3992.155 ±    304.559  ops/s

This Branch

Benchmark                                                            (size)     (testCase)  (validatorType)   Mode  Cnt         Score        Error  Units
OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete       2            N/A              Old  thrpt   25     19026.073 ±    164.906  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete       2            N/A              New  thrpt   25     20151.243 ±    184.578  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete      10            N/A              Old  thrpt   25      5938.218 ±     55.671  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete      10            N/A              New  thrpt   25      6514.865 ±     55.536  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete     100            N/A              Old  thrpt   25       165.986 ±      1.271  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkDeepAbstractConcrete     100            N/A              New  thrpt   25       735.274 ±      4.754  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapFrag              2            N/A              Old  thrpt   25     71664.893 ±    492.134  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapFrag              2            N/A              New  thrpt   25     43390.597 ±    661.312  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapFrag             10            N/A              Old  thrpt   25      2964.733 ±     24.362  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapFrag             10            N/A              New  thrpt   25      9591.335 ±    134.486  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapFrag            100            N/A              Old  thrpt   25         0.392 ±      0.005  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapFrag            100            N/A              New  thrpt   25       969.408 ±     15.881  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapNoFrag            2            N/A              Old  thrpt   25    141902.486 ±   2658.361  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapNoFrag            2            N/A              New  thrpt   25     67100.623 ±   1043.107  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapNoFrag           10            N/A              Old  thrpt   25     15499.696 ±    146.726  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapNoFrag           10            N/A              New  thrpt   25     16870.248 ±     70.415  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapNoFrag          100            N/A              Old  thrpt   25        45.347 ±      0.294  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkNoOverlapNoFrag          100            N/A              New  thrpt   25      1693.601 ±     14.617  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapFrag                2            N/A              Old  thrpt   25     35581.559 ±    378.258  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapFrag                2            N/A              New  thrpt   25     38966.950 ±    412.514  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapFrag               10            N/A              Old  thrpt   25      1111.010 ±      8.733  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapFrag               10            N/A              New  thrpt   25     10367.708 ±     73.396  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapFrag              100            N/A              Old  thrpt   25         0.332 ±      0.003  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapFrag              100            N/A              New  thrpt   25      1008.495 ±      7.106  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapNoFrag              2            N/A              Old  thrpt   25     86045.383 ±    528.934  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapNoFrag              2            N/A              New  thrpt   25     58704.199 ±    518.841  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapNoFrag             10            N/A              Old  thrpt   25      4027.155 ±     15.102  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapNoFrag             10            N/A              New  thrpt   25     16382.657 ±     84.072  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapNoFrag            100            N/A              Old  thrpt   25         1.631 ±      0.006  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkOverlapNoFrag            100            N/A              New  thrpt   25      1668.501 ±     11.055  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkRepeatedFields             2            N/A              Old  thrpt   25    163585.603 ±   1174.354  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkRepeatedFields             2            N/A              New  thrpt   25     76163.932 ±    490.155  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkRepeatedFields            10            N/A              Old  thrpt   25     45146.290 ±   1090.833  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkRepeatedFields            10            N/A              New  thrpt   25     37169.817 ±    293.824  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkRepeatedFields           100            N/A              Old  thrpt   25       374.096 ±     70.632  ops/s
OverlappingFieldsCanBeMergedBenchmark.benchmarkRepeatedFields           100            N/A              New  thrpt   25      5442.697 ±     35.733  ops/s
StringUtilBenchmark.benchCurrent                                        N/A    empty input              N/A  thrpt   25   3069666.882 ± 157380.347  ops/s
StringUtilBenchmark.benchCurrent                                        N/A  empty options              N/A  thrpt   25  13800116.262 ±  33431.318  ops/s
StringUtilBenchmark.benchCurrent                                        N/A            abc              N/A  thrpt   25    389430.745 ±   4980.061  ops/s
StringUtilBenchmark.benchCurrent                                        N/A    description              N/A  thrpt   25     68312.093 ±   7890.884  ops/s
StringUtilBenchmark.benchCurrent                                        N/A         length              N/A  thrpt   25      4109.628 ±    292.646  ops/s

The StringUtilBenchmark difference (presumably a baseline) is pretty bizzare, and it looks like maybe these machines were under very different conditions. I am re-running again, since I think this would only be a fair comparison with our baseline closer together. The benchmarking SHALL CONTINUE!

@nickhudkins
Copy link
Contributor Author

A quick comparison in excel, this is showing this branch's performance (advantage/disadvantage) in the far right column.

Any difference larger than 2% has been indicated with a green arrow, anything 0-2% are yellow, and any thing where it did not perform as well has a red arrow.

Screen Shot 2021-01-08 at 9 49 56 AM

@nickhudkins nickhudkins marked this pull request as ready for review January 8, 2021 14:51
Copy link
Contributor

@yanns yanns left a comment

Choose a reason for hiding this comment

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

👍
Thanks for the deep investigation!

@nickhudkins nickhudkins merged commit cbf7282 into master Jan 8, 2021
@nickhudkins nickhudkins deleted the perf-senstive-refactorings branch January 8, 2021 15:05
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