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 new ConsumerSettings::enableOptimisticResume setting (true by default) to allow users to disable the "optimistic resume" optimisation && Write benchmarks where this optimisation is disabled #889

Merged
merged 5 commits into from
Jun 3, 2023

Conversation

guizmaii
Copy link
Member

@guizmaii guizmaii commented Jun 2, 2023

Benchmark results

Before

zioKafkaBench/Jmh/run -wi 10 -i 10 -r 1 -w 1 -t 1 -f 3 -foe true .*ConsumersComparisonBenchmark*
...
[info] Benchmark                                        Mode  Cnt     Score     Error  Units
[info] ConsumersComparisonBenchmark.kafkaClients        avgt   30   645.361 ±   3.004  ms/op
[info] ConsumersComparisonBenchmark.manualKafkaClients  avgt   30   641.042 ±   2.877  ms/op
[info] ConsumersComparisonBenchmark.manualZioKafka      avgt   30  2651.134 ± 100.297  ms/op
[info] ConsumersComparisonBenchmark.zioKafka            avgt   30   739.566 ±  21.019  ms/op

After

zioKafkaBench/Jmh/run -wi 10 -i 10 -r 1 -w 1 -t 1 -f 3 -foe true .*comparison.*
...
[info] Result "zio.kafka.bench.comparison.KafkaClientBenchmarks.kafkaClients":
[info]   641.438 ±(99.9%) 3.349 ms/op [Average]
[info]   (min, avg, max) = (624.941, 641.438, 650.032), stdev = 5.012
[info]   CI (99.9%): [638.090, 644.787] (assumes normal distribution)
...
[info] Result "zio.kafka.bench.comparison.KafkaClientBenchmarks.manualKafkaClients":
[info]   642.514 ±(99.9%) 3.090 ms/op [Average]
[info]   (min, avg, max) = (632.069, 642.514, 656.932), stdev = 4.625
[info]   CI (99.9%): [639.424, 645.605] (assumes normal distribution)
...
[info] Result "zio.kafka.bench.comparison.ZioKafkaBenchmarks.manualZioKafka":
[info]   2605.392 ±(99.9%) 229.199 ms/op [Average]
[info]   (min, avg, max) = (1584.064, 2605.392, 2818.016), stdev = 343.055
[info]   CI (99.9%): [2376.193, 2834.592] (assumes normal distribution)
...
[info] Result "zio.kafka.bench.comparison.ZioKafkaBenchmarks.zioKafka":
[info]   734.987 ±(99.9%) 22.830 ms/op [Average]
[info]   (min, avg, max) = (683.740, 734.987, 826.528), stdev = 34.170
[info]   CI (99.9%): [712.158, 757.817] (assumes normal distribution)
...
[info] Result "zio.kafka.bench.comparison.ZioKafkaNoOptimisticResumeBenchmarks.manualZioKafka":
[info]   819.937 ±(99.9%) 120.082 ms/op [Average]
[info]   (min, avg, max) = (683.373, 819.937, 1243.105), stdev = 179.733
[info]   CI (99.9%): [699.855, 940.019] (assumes normal distribution)
...
[info] Result "zio.kafka.bench.comparison.ZioKafkaNoOptimisticResumeBenchmarks.zioKafka":
[info]   1311.588 ±(99.9%) 212.646 ms/op [Average]
[info]   (min, avg, max) = (755.915, 1311.588, 2329.325), stdev = 318.279
[info]   CI (99.9%): [1098.942, 1524.234] (assumes normal distribution)
...
[info] Benchmark                                            Mode  Cnt     Score     Error  Units
[info] KafkaClientBenchmarks.kafkaClients                   avgt   30   641.438 ±   3.349  ms/op
[info] KafkaClientBenchmarks.manualKafkaClients             avgt   30   642.514 ±   3.090  ms/op
[info] ZioKafkaBenchmarks.manualZioKafka                    avgt   30  2605.392 ± 229.199  ms/op
[info] ZioKafkaBenchmarks.zioKafka                          avgt   30   734.987 ±  22.830  ms/op
[info] ZioKafkaNoOptimisticResumeBenchmarks.manualZioKafka  avgt   30   819.937 ± 120.082  ms/op
[info] ZioKafkaNoOptimisticResumeBenchmarks.zioKafka        avgt   30  1311.588 ± 212.646  ms/op

Observations

Interestingly, the optimistic resume optimisation seems to be very detrimental to the manual consumption performances

Copy link
Collaborator

@erikvanoosten erikvanoosten left a comment

Choose a reason for hiding this comment

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

There is no reason to inline Chunk.foreach and I prefer positive wording for the feature name. Otherwise this PR LGTM.

BTW, I didn't check the benchmark related code in detail.

@guizmaii guizmaii marked this pull request as ready for review June 2, 2023 13:08
@guizmaii guizmaii changed the title Add new ConsumerSettings::disableOptimisticResume setting to allow users to disable the "optimistic resume" optimisation && Write benchmarks where this optimisation is disabled Add new ConsumerSettings::enableOptimisticResume setting (true by default) to allow users to disable the "optimistic resume" optimisation && Write benchmarks where this optimisation is disabled Jun 2, 2023
@guizmaii
Copy link
Member Author

guizmaii commented Jun 2, 2023

BTW, I didn't check the benchmark related code in detail.

I just re-organised and copy/pasted the already existing benchmarks.
It's the only way to be able to have different sets of settings if we want to keep the instantiation of the Consumer outside of the benchmarked code (which I absolutely want)

Copy link
Collaborator

@erikvanoosten erikvanoosten left a comment

Choose a reason for hiding this comment

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

I am still wondering if we should call the setting optimisticResume instead of enableOptimisticResume 🤷

@guizmaii
Copy link
Member Author

guizmaii commented Jun 3, 2023

I am still wondering if we should call the setting optimisticResume instead of enableOptimisticResume 🤷

enableOptimisticResume is more explicit

Copy link
Collaborator

@svroonland svroonland left a comment

Choose a reason for hiding this comment

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

Good for users to be able to toggle this feature to see the effect on performance

@guizmaii guizmaii force-pushed the optimistic_resume_optional branch from e4ae988 to aa9c153 Compare June 3, 2023 07:48
@guizmaii guizmaii force-pushed the optimistic_resume_optional branch from 04934a1 to bf4f562 Compare June 3, 2023 07:52
@guizmaii guizmaii merged commit ef8ebef into master Jun 3, 2023
4 of 11 checks passed
@guizmaii guizmaii deleted the optimistic_resume_optional branch June 3, 2023 07:53
erikvanoosten added a commit that referenced this pull request Jun 3, 2023
erikvanoosten added a commit that referenced this pull request Jun 3, 2023
erikvanoosten added a commit that referenced this pull request Jun 3, 2023
erikvanoosten added a commit that referenced this pull request Jun 3, 2023
erikvanoosten added a commit that referenced this pull request Jun 3, 2023
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

3 participants