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

Allow to configure ack-timeout tick time #4760

Merged
merged 1 commit into from
Jul 21, 2019

Conversation

merlimat
Copy link
Contributor

Motivation

After the changes in #3118, there has a been a sharp increase of memory utilization for the UnackedMessageTracker due to the time buckets being created.

This is especially true when the acktimeout is set to a larger value (eg: 1h) where 3600 time-buckets are being created. This lead to use 20MB per partition even when no message is tracked.

Allowing to configure the tick time so that application can tune it based on needs.

Additionally, fixed the logic that keeps creating hash maps and throwing them away at each tick time iteration, since that creates a lot of garbage and doesn't take care of the fact that the hash maps are expanding based on the required capacity (so next time they are already of the "right" size).

On a final note: the current default of 1sec seems very wasteful. Something like 10s should be more appropriate as default.

@merlimat merlimat added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Jul 18, 2019
@merlimat merlimat added this to the 2.4.1 milestone Jul 18, 2019
@merlimat merlimat self-assigned this Jul 18, 2019
Copy link
Contributor

@codelipenghui codelipenghui left a comment

Choose a reason for hiding this comment

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

Look good to me +1

10 sec by default is ok, if user use a short ack timeout (less than 10s), it’s better to use ack timeout as the tick time. means ack timeout always >= tick time.

@jiazhai
Copy link
Member

jiazhai commented Jul 19, 2019

run java8 tests
run integration tests

java8 failures:
org.apache.pulsar.client.api.SimpleProducerConsumerTest.testActiveAndInActiveConsumerEntryCacheBehavior

integration failures:
org.apache.pulsar.tests.integration.functions.PulsarFunctionsProcessTest.pulsar-test-suite
org.apache.pulsar.tests.integration.functions.PulsarFunctionsProcessTest.pulsar-test-suite
org.apache.pulsar.tests.integration.functions.PulsarFunctionsThreadTest.pulsar-test-suite
org.apache.pulsar.tests.integration.functions.PulsarFunctionsThreadTest.pulsar-test-suite
org.apache.pulsar.tests.integration.functions.PulsarFunctionsThreadTest.pulsar-test-suite
org.apache.pulsar.tests.integration.offload.TestS3Offload.tiered-storage-test-suite

@sijie
Copy link
Member

sijie commented Jul 21, 2019

run java8 tests
run integration tests

@sijie sijie merged commit f13af48 into apache:master Jul 21, 2019
@merlimat
Copy link
Contributor Author

@codelipenghui Another option I was thinking of, was to just keep a fixed number of time buckets, say like 16 (non configurable). That will automatically tie the precision the order of magnitude of the ack timeout.

@codelipenghui
Copy link
Contributor

@merlimat

Another option I was thinking of, was to just keep a fixed number of time buckets, say like 16 (non configurable). That will automatically tie the precision the order of magnitude of the ack timeout.

I think it can be used as the default configuration, but it's better for users to configure it.

easyfan pushed a commit to easyfan/pulsar that referenced this pull request Jul 26, 2019
### Motivation

After the changes in apache#3118, there has a been a sharp increase of memory utilization for the UnackedMessageTracker due to the time buckets being created. 

This is especially true when the acktimeout is set to a larger value (eg: 1h) where 3600 time-buckets are being created. This lead to use 20MB per partition even when no message is tracked.

Allowing to configure the tick time so that application can tune it based on needs.

Additionally, fixed the logic that keeps creating hash maps and throwing them away at each tick time iteration, since that creates a lot of garbage and doesn't take care of the fact that the hash maps are expanding based on the required capacity (so next time they are already of the "right" size). 

On a final note: the current default of 1sec seems very wasteful. Something like 10s should be more appropriate as default.
jiazhai pushed a commit that referenced this pull request Aug 28, 2019
### Motivation

After the changes in #3118, there has a been a sharp increase of memory utilization for the UnackedMessageTracker due to the time buckets being created.

This is especially true when the acktimeout is set to a larger value (eg: 1h) where 3600 time-buckets are being created. This lead to use 20MB per partition even when no message is tracked.

Allowing to configure the tick time so that application can tune it based on needs.

Additionally, fixed the logic that keeps creating hash maps and throwing them away at each tick time iteration, since that creates a lot of garbage and doesn't take care of the fact that the hash maps are expanding based on the required capacity (so next time they are already of the "right" size).

On a final note: the current default of 1sec seems very wasteful. Something like 10s should be more appropriate as default.

(cherry picked from commit f13af48)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants