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

refactor: compact pending-acks #78

Merged
merged 3 commits into from
Sep 11, 2024

Conversation

zmstone
Copy link
Contributor

@zmstone zmstone commented Sep 10, 2024

Prior to this change, the producer uses a map to hold pending acks under the assumption that the map values should be small.
in some complex scenarios, however, the ack callback contexts can be large terms this result in great RAM consumption when there are many to ack.

This PR optimizes RAM usage by:

  1. Change the call IDs to sequential
  2. Do not store a copy of the context if it's identical to the last call.

@zmstone zmstone force-pushed the 0909-support-static-ack-callbacks branch 3 times, most recently from c49ad22 to f6e2f56 Compare September 10, 2024 20:32
src/wolff_pendack.erl Outdated Show resolved Hide resolved
Comment on lines +92 to +91
-spec take(acks(), call_id()) -> {ok, cb(), acks()} | false.
take(#{cbs := Cbs} = X, Id) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: since this might receive a disk queue item containing ?no_caller_ack as the call id, maybe it should immediately return false if such value is the input?

Copy link
Contributor Author

@zmstone zmstone Sep 10, 2024

Choose a reason for hiding this comment

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

no_caller_ack was a left-over (forgot to delete) when I refactored the batch split algorithm.

My previous iteration of the batch-split algorithm tried to split the batch of a call.
Given one call only needed one ack, I added no_caller_ack for the rest of the split-items.
This caused a lot complexity, later I refactored it to drop the entire call if the batch is too large, but I forgot to remove no_caller_ack.

test/wolff_dynamic_topics_tests.erl Outdated Show resolved Hide resolved
@zmstone zmstone force-pushed the 0909-support-static-ack-callbacks branch from f6e2f56 to c401ed2 Compare September 10, 2024 21:11
@zmstone zmstone merged commit 7bb150b into kafka4beam:main Sep 11, 2024
6 checks passed
@zmstone zmstone deleted the 0909-support-static-ack-callbacks branch September 11, 2024 06:54
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.

2 participants