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

Commit offsets at specified intervals #1405

Conversation

pierDipi
Copy link
Member

@pierDipi pierDipi commented Nov 3, 2021

Committing offsets at a specified interval reduces Kafka cluster
load and makes the event delivery hundreds of times faster.

auto.commit.interval.ms is used to determine the commit
interval.

Proposed Changes

  • Commit offsets at specified intervals

Release Note

Kafka Broker event delivery is hundreds of times faster

Docs

None

@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 3, 2021
@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Nov 3, 2021
@knative-prow-robot knative-prow-robot added area/data-plane size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 3, 2021
@codecov
Copy link

codecov bot commented Nov 3, 2021

Codecov Report

Merging #1405 (b582863) into main (f8f2a9b) will decrease coverage by 5.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1405      +/-   ##
============================================
- Coverage     76.24%   71.19%   -5.05%     
+ Complexity      584      575       -9     
============================================
  Files            98       99       +1     
  Lines          3658     3906     +248     
  Branches        166      160       -6     
============================================
- Hits           2789     2781       -8     
- Misses          653      909     +256     
  Partials        216      216              
Flag Coverage Δ
java-unittests 82.16% <100.00%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...a/broker/dispatcher/impl/RecordDispatcherImpl.java 81.92% <100.00%> (-0.64%) ⬇️
...broker/dispatcher/impl/consumer/OffsetManager.java 100.00% <100.00%> (ø)
...r/dispatcher/main/ConsumerVerticleFactoryImpl.java 88.07% <100.00%> (+1.58%) ⬆️
control-plane/pkg/reconciler/kafka/topic.go 97.67% <0.00%> (-2.33%) ⬇️
control-plane/pkg/reconciler/broker/broker.go 70.44% <0.00%> (ø)
control-plane/pkg/reconciler/sink/kafka_sink.go 67.83% <0.00%> (ø)
...lane/pkg/reconciler/base/receiver_condition_set.go 0.00% <0.00%> (ø)
control-plane/pkg/reconciler/channel/channel.go 0.00% <0.00%> (ø)
control-plane/pkg/reconciler/channel/controller.go 85.71% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f8f2a9b...b582863. Read the comment docs.

@pierDipi pierDipi force-pushed the SRVKE_Perf_commit-interval branch 7 times, most recently from d2ad17b to 73e28f8 Compare November 4, 2021 09:20
@pierDipi
Copy link
Member Author

pierDipi commented Nov 4, 2021

artifacts.tar.gz

@pierDipi pierDipi changed the title [WIP] [Ignore] Commit offsets at specified intervals Nov 4, 2021
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 4, 2021
@pierDipi pierDipi changed the title Commit offsets at specified intervals [wip] Commit offsets at specified intervals Nov 4, 2021
@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 4, 2021
@pierDipi
Copy link
Member Author

pierDipi commented Nov 4, 2021

/cherry-pick release-1.0

@knative-prow-robot
Copy link
Contributor

@pierDipi: once the present PR merges, I will cherry-pick it on top of release-1.0 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.0

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@pierDipi
Copy link
Member Author

pierDipi commented Nov 4, 2021

/cherry-pick release-0.26

@knative-prow-robot
Copy link
Contributor

@pierDipi: once the present PR merges, I will cherry-pick it on top of release-0.26 in a new PR and assign it to you.

In response to this:

/cherry-pick release-0.26

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@pierDipi
Copy link
Member Author

pierDipi commented Nov 4, 2021

/cherry-pick release-0.25

@knative-prow-robot
Copy link
Contributor

@pierDipi: once the present PR merges, I will cherry-pick it on top of release-0.25 in a new PR and assign it to you.

In response to this:

/cherry-pick release-0.25

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@pierDipi pierDipi changed the title [wip] Commit offsets at specified intervals Commit offsets at specified intervals Nov 4, 2021
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 4, 2021
case UNORDERED -> new UnorderedOffsetManager(consumer, commitHandler);
};
}

private static AbstractVerticle getConsumerVerticle(final DeliveryOrder type,
Copy link
Contributor

Choose a reason for hiding this comment

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

So, one Offset mgr is used for the (Un)Ordered Consumers - ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, there is no need to keep 2 separate components and implement the same commit interval logic in 2 places.

The offset tracker overhead in the ordered case is constant.

@@ -178,14 +172,15 @@ public AbstractVerticle get(final DataPlaneContract.Resource resource, final Dat
Filter.noop();

final var responseHandler = getNoopResponseHandlerOrDefault(egress, () -> getKafkaResponseHandler(vertx, producerConfigs, resource));
final var commitIntervalMs = Integer.parseInt(String.valueOf(consumerConfigs.get(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG)));
Copy link
Contributor

Choose a reason for hiding this comment

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

should we document this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I'll open an issue in knative/docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@pierDipi pierDipi requested review from aliok and matzew November 5, 2021 08:01
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
@pierDipi pierDipi force-pushed the SRVKE_Perf_commit-interval branch from 73e28f8 to d2776e4 Compare November 8, 2021 10:06
@pierDipi pierDipi changed the title [wip] Commit offsets at specified intervals Commit offsets at specified intervals Nov 8, 2021
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 8, 2021
blackhole.consume(
offsetManager.recordReceived(recordsState.records[partition][0])
);
offsetManager.recordReceived(recordsState.records[partition][0]);
Copy link
Contributor

Choose a reason for hiding this comment

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

are they directly consumed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the code to make it compile but I'm inclined to drop these OffsetManager benchmarks since they are not really useful to catch perf regressions as they are.

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>
Copy link
Contributor

@matzew matzew left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@@ -178,14 +172,15 @@ public AbstractVerticle get(final DataPlaneContract.Resource resource, final Dat
Filter.noop();

final var responseHandler = getNoopResponseHandlerOrDefault(egress, () -> getKafkaResponseHandler(vertx, producerConfigs, resource));
final var commitIntervalMs = Integer.parseInt(String.valueOf(consumerConfigs.get(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG)));
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 9, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: matzew, pierDipi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@matzew
Copy link
Contributor

matzew commented Nov 9, 2021

@pierDipi should we backport this to 0.27 ? (and perhaps 0.26 - if possible) ?

@pierDipi
Copy link
Member Author

pierDipi commented Nov 9, 2021

Prow will do that #1405 (comment)

@pierDipi
Copy link
Member Author

pierDipi commented Nov 9, 2021

and #1405 (comment)

@knative-prow-robot
Copy link
Contributor

@pierDipi: new pull request created: #1449

In response to this:

/cherry-pick release-1.0

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow-robot
Copy link
Contributor

@pierDipi: #1405 failed to apply on top of branch "release-0.26":

Applying: Commit offset at a specified interval
Using index info to reconstruct a base tree...
M	data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/impl/RecordDispatcherImpl.java
M	data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/main/ConsumerVerticleFactoryImpl.java
M	data-plane/dispatcher/src/test/java/dev/knative/eventing/kafka/broker/dispatcher/impl/RecordDispatcherTest.java
M	data-plane/tests/src/test/java/dev/knative/eventing/kafka/broker/tests/DataPlaneTest.java
Falling back to patching base and 3-way merge...
Auto-merging data-plane/tests/src/test/java/dev/knative/eventing/kafka/broker/tests/DataPlaneTest.java
CONFLICT (content): Merge conflict in data-plane/tests/src/test/java/dev/knative/eventing/kafka/broker/tests/DataPlaneTest.java
Removing data-plane/dispatcher/src/test/java/dev/knative/eventing/kafka/broker/dispatcher/impl/consumer/OrderedOffsetManagerTest.java
Auto-merging data-plane/dispatcher/src/test/java/dev/knative/eventing/kafka/broker/dispatcher/impl/RecordDispatcherTest.java
Auto-merging data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/main/ConsumerVerticleFactoryImpl.java
CONFLICT (content): Merge conflict in data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/main/ConsumerVerticleFactoryImpl.java
Removing data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/impl/consumer/UnorderedOffsetManager.java
Removing data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/impl/consumer/OrderedOffsetManager.java
Auto-merging data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/impl/RecordDispatcherImpl.java
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Commit offset at a specified interval
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-0.26

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow-robot
Copy link
Contributor

@pierDipi: #1405 failed to apply on top of branch "release-0.25":

Applying: Commit offset at a specified interval
Using index info to reconstruct a base tree...
M	data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/impl/RecordDispatcherImpl.java
M	data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/main/ConsumerVerticleFactoryImpl.java
M	data-plane/dispatcher/src/test/java/dev/knative/eventing/kafka/broker/dispatcher/impl/RecordDispatcherTest.java
M	data-plane/tests/src/test/java/dev/knative/eventing/kafka/broker/tests/DataPlaneTest.java
Falling back to patching base and 3-way merge...
Auto-merging data-plane/tests/src/test/java/dev/knative/eventing/kafka/broker/tests/DataPlaneTest.java
CONFLICT (content): Merge conflict in data-plane/tests/src/test/java/dev/knative/eventing/kafka/broker/tests/DataPlaneTest.java
Removing data-plane/dispatcher/src/test/java/dev/knative/eventing/kafka/broker/dispatcher/impl/consumer/OrderedOffsetManagerTest.java
Auto-merging data-plane/dispatcher/src/test/java/dev/knative/eventing/kafka/broker/dispatcher/impl/RecordDispatcherTest.java
Auto-merging data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/main/ConsumerVerticleFactoryImpl.java
CONFLICT (content): Merge conflict in data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/main/ConsumerVerticleFactoryImpl.java
Removing data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/impl/consumer/UnorderedOffsetManager.java
Removing data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/impl/consumer/OrderedOffsetManager.java
Auto-merging data-plane/dispatcher/src/main/java/dev/knative/eventing/kafka/broker/dispatcher/impl/RecordDispatcherImpl.java
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Commit offset at a specified interval
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-0.25

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@pierDipi pierDipi deleted the SRVKE_Perf_commit-interval branch November 9, 2021 19:37
pierDipi added a commit to pierDipi/eventing-kafka-broker that referenced this pull request Nov 9, 2021
* Commit offset at a specified interval

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Add reset logic to handle long large offsets

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Use final

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>
knative-prow-robot pushed a commit that referenced this pull request Nov 10, 2021
* Commit offsets at specified intervals (#1405)

* Commit offset at a specified interval

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Add reset logic to handle long large offsets

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Use final

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>

* Update codegen

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* ko upgrade fixes

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>
knative-prow-robot pushed a commit to knative-prow-robot/eventing-kafka-broker that referenced this pull request Nov 10, 2021
* Commit offset at a specified interval

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Add reset logic to handle long large offsets

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Use final

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>
matzew added a commit to matzew/eventing-kafka-broker that referenced this pull request Nov 10, 2021
…ons#1405) (knative-extensions#1450)

* Commit offsets at specified intervals (knative-extensions#1405)

* Commit offset at a specified interval

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Add reset logic to handle long large offsets

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Use final

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>

* Update codegen

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* ko upgrade fixes

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>
knative-prow-robot added a commit that referenced this pull request Nov 10, 2021
…1405) (#1454)

* Commit offsets at specified intervals (#1405)

* Commit offset at a specified interval

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Add reset logic to handle long large offsets

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Use final

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>

* Update codegen

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* ko upgrade fixes

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

Co-authored-by: Pierangelo Di Pilato <pdipilat@redhat.com>
Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>
matzew added a commit to matzew/eventing-kafka-broker that referenced this pull request Nov 10, 2021
…ons#1405) (knative-extensions#1450)

* Commit offsets at specified intervals (knative-extensions#1405)

* Commit offset at a specified interval

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Add reset logic to handle long large offsets

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Use final

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>

* Update codegen

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* ko upgrade fixes

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>
pierDipi added a commit to pierDipi/eventing-kafka-broker that referenced this pull request Nov 12, 2021
…ons#1405) (knative-extensions#1450)

* Commit offsets at specified intervals (knative-extensions#1405)

* Commit offset at a specified interval

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Add reset logic to handle long large offsets

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Use final

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>

* Update codegen

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* ko upgrade fixes

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/data-plane cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants