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

proposal for #2209 #2216

Closed
wants to merge 14 commits into from
Closed

proposal for #2209 #2216

wants to merge 14 commits into from

Conversation

dfa1
Copy link
Contributor

@dfa1 dfa1 commented Feb 18, 2021

@andimarek tentative implementation for avoiding some copies in MergedField&co

On my old macbook (2013) I get these numbers:

# Warmup Iteration   1: 33.139 ops/s
# Warmup Iteration   2: 69.119 ops/s
Iteration   1: 53.670 ops/s
Iteration   2: 53.648 ops/s
Iteration   3: 54.286 ops/s

usually I get 50 ops/s in this benchmark . Can you please double check?

/cc @bbakerman not sure if I'm following the "mutable builder"/"immutable object" pattern. For sure, the type signature are much hard to read now.... please advise :)

@andimarek
Copy link
Member

@dfa1 can you post the before and after numbers for your local environment? thanks

@dfa1
Copy link
Contributor Author

dfa1 commented Feb 23, 2021

Before (master 6ffdd2d):

Benchmark                                    Mode  Cnt   Score   Error  Units
BenchMark.benchMarkSimpleQueriesThroughput  thrpt   15  50.032 ± 1.863  ops/s
BenchMark.benchMarkSimpleQueriesAvgTime      avgt   15  18.856 ± 0.266  ms/op

This branch:

Benchmark                                    Mode  Cnt   Score   Error  Units
BenchMark.benchMarkSimpleQueriesThroughput  thrpt   15  52.851 ± 1.182  ops/s
BenchMark.benchMarkSimpleQueriesAvgTime      avgt   15  19.317 ± 0.306  ms/op

Better throughput but also bigger avg time!

NB: @andimarek since this benchmark is using TracingInstrumentation the results are less predictable (much more objects created/destroyed)

@dfa1
Copy link
Contributor Author

dfa1 commented Feb 23, 2021

interesting! Without TracingInstrumentation I see that this PR is actually making things worse!

master:

Benchmark                                    Mode  Cnt   Score   Error  Units
BenchMark.benchMarkSimpleQueriesThroughput  thrpt   15  98.325 ± 3.686  ops/s
BenchMark.benchMarkSimpleQueriesAvgTime      avgt   15  10.242 ± 0.185  ms/op

this branch:

Benchmark                                    Mode  Cnt   Score   Error  Units
BenchMark.benchMarkSimpleQueriesThroughput  thrpt   15  94.184 ± 3.373  ops/s
BenchMark.benchMarkSimpleQueriesAvgTime      avgt   15  10.572 ± 0.386  ms/op

@bbakerman bbakerman linked an issue Feb 26, 2021 that may be closed by this pull request
@@ -77,7 +74,7 @@ private MergedField(List<Field> fields) {
* @return the name of of the merged fields.
*/
public String getName() {
return singleField.getName();
return fields.get(0).getName();
Copy link
Member

Choose a reason for hiding this comment

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

Rather than do a list by index look up everytime we need name, do it once at construction into a String name field

Copy link
Member

Choose a reason for hiding this comment

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

Or cache the field since its used everywhere

Benchmark                                    Mode  Cnt   Score   Error  Units
BenchMark.benchMarkSimpleQueriesThroughput  thrpt   15  55.953 ± 1.093  ops/s
BenchMark.benchMarkSimpleQueriesAvgTime      avgt   15  18.106 ± 0.245  ms/op
@dfa1
Copy link
Contributor Author

dfa1 commented Feb 26, 2021

Tested the idea quickly, since the Benchmark is always using one field per MergedField:

Before (master 6ffdd2d):

Benchmark                                    Mode  Cnt   Score   Error  Units
BenchMark.benchMarkSimpleQueriesThroughput  thrpt   15  50.032 ± 1.863  ops/s
BenchMark.benchMarkSimpleQueriesAvgTime      avgt   15  18.856 ± 0.266  ms/op
Benchmark                                    Mode  Cnt   Score   Error  Units
BenchMark.benchMarkSimpleQueriesThroughput  thrpt   15  55.953 ± 1.093  ops/s
BenchMark.benchMarkSimpleQueriesAvgTime      avgt   15  18.106 ± 0.245  ms/op

So this is interesting: there is some overhead that we could kill between MergedField and MergedSelectionSet. Not sure what is the best way... here I'm taking too many shortcuts (i.e. allocating directly the object, skipping completely the builder!)

@dfa1
Copy link
Contributor Author

dfa1 commented Mar 24, 2021

@bbakerman @andimarek I give up on this PR.... I hope that we have some more data about what is the bottleneck!

@dfa1 dfa1 closed this Mar 24, 2021
@andimarek
Copy link
Member

andimarek commented Mar 24, 2021

Sorry @dfa1 that we didn't come back in time but as you know it happen sometimes.

@dfa1
Copy link
Contributor Author

dfa1 commented Mar 24, 2021

no worries @andimarek! I tried several things and none of them worked 100% for all use cases!

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.

Field Collector as possible optimization
3 participants