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

ARTEMIS-4809 Allow configuring initial queue buffer size #4966

Closed
wants to merge 1 commit into from

Conversation

joshb1050
Copy link
Contributor

@joshb1050 joshb1050 commented Jun 7, 2024

In some setups, there could be a few hundred thousand queues that are created due to many consumers that are connecting. However, most of these are empty and stay empty for the entire day since there aren't necessarily messages to be sent. The 8K intermediateMessageReferences instantiates an 64KB buffer (Object[]). This means we have large allocation and live heap that ultimately remains empty for almost the entire day.

In this commit, we introduce initial-queue-buffer-size, which defaults to the current value of 8192. It can be set programmatically via
QueueConfiguration#setInitialQueueBufferSize(int).

Note that this must be a power of 2.

@jbertram
Copy link
Contributor

jbertram commented Jun 7, 2024

Thanks for the PR!

I think this would be better as an address-setting so you could easily configure large swaths of queues. Right now there's no way to configure this via broker.xml. It can only be configured if you're directly creating the queue(s) programmatically.

Lastly, there's no tests or documentation for this new setting. Tests are mandatory to ensure the functionality works properly and to mitigate future regressions.

@joshb1050
Copy link
Contributor Author

joshb1050 commented Jun 10, 2024

Thanks @jbertram! I have updated my PR to make this configurable on a per-address basis and via XML as well. I have also added tests and documentation for the functionality. Please let me know if there is a different approach I should be taking here.

@joshb1050
Copy link
Contributor Author

Checkstyle is fixed now as well.

@jbertram
Copy link
Contributor

For what it's worth you can run checkstyle locally using:

mvn -Pdev install

See the hacking guide for more details.

@joshb1050
Copy link
Contributor Author

joshb1050 commented Jun 11, 2024

@jbertram thank you—it's strange since I did run mvn checkstyle:check and mvn -Pdev install and both passed even with the checkstyle error locally. It's also unclear given that check passed for 2 of the 3 failures. I have corrected the latest one that I see on CI though.

@joshb1050
Copy link
Contributor Author

Hi @jbertram, any feedback on this?

@gemmellr
Copy link
Member

@jbertram thank you—it's strange since I did run mvn checkstyle:check and mvn -Pdev install and both passed even with the checkstyle error locally. It's also unclear given that check passed for 2 of the 3 failures. I have corrected the latest one that I see on CI though.

The last failure you had on 1 of the 3 'check' jobs, was actually from ErrorProne rather than Checkstyle, due to missing an @ Override. There is a different ErrorProne profile used on JDK 11+ builds and JDK16+ (i.e the JDK 17 and 21 CI runs), and that latter profile also does not check the @ Override condition, because a Java 15 class signature change meant that one (or more, I forget) of the classes in the codebase actually violates that on Java 15+ but not on earlier versions (aside: I deliberately left 15 hanging when adapting the other profile for 16/17+, since it was out of support anyway).

This came up because in the past, the JDK > 11 runs were all using their own newer compile signatures, because we couldnt set the maven.compiler.release flag at the time. That is actually recently in place, so theyll all now be using the JDK11 method signatures now, hopefully meaning that issue shouldnt be present any more and I can adjust it to error on missing @ Override again in the JDK16+ profile too for consistency.

@gemmellr
Copy link
Member

ErrorProne check on JDK16+ adjusted in 6584220

@joshb1050
Copy link
Contributor Author

Hi @gemmellr @jbertram can I please get a re-review on this?

if ((value.longValue() & (value.longValue() - 1)) == 0 && value.longValue() > 0) {
return value;
} else {
throw ActiveMQMessageBundle.BUNDLE.powerOfTwo(name, value);
Copy link
Member

Choose a reason for hiding this comment

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

if the validator is being called POSITIVE_POWER_OF_TWO would it make sense for the exception bundle method to be specific as well?

@gemmellr
Copy link
Member

gemmellr commented Aug 2, 2024

Spotted a few small niggles, nothing serious.

Would like Justin or someone else more familiar to also review.

@jbertram
Copy link
Contributor

jbertram commented Aug 2, 2024

Generally speaking I think this looks good. However, there's a couple of things I would revisit:

  1. The name intermediate-message-buffer-initial-size, while technically accurate, is probably not terribly clear to users. I think something like initial-queue-buffer-size is more clear.
  2. The documentation defines this as the " initial number of elements of the intermediate message reference buffer." Again, this is technically accurate, but it doesn't give users a clear reason why they might want to configure it. The docs should make clear that this is tied directly to the number of bytes from the JVM's heap each queue will consume initially. The docs might also mention the canonical use-case for this (i.e. lots of queues which might remain empty or have a small number of messages).

@joshb1050 joshb1050 changed the title ARTEMIS-4809 Allow configuring intermediateMessageReferences size ARTEMIS-4809 Allow configuring initial message buffer size Aug 2, 2024
@joshb1050 joshb1050 changed the title ARTEMIS-4809 Allow configuring initial message buffer size ARTEMIS-4809 Allow configuring initial queue buffer size Aug 2, 2024
In some setups, there could be a few hundred thousand queues that are
created due to many consumers that are connecting. However, most of
these are empty and stay empty for the entire day since there aren't
necessarily messages to be sent. The 8K intermediateMessageReferences
instantiates an 64KB buffer (Object[]). This means we have large
allocation and live heap that ultimately remains empty for almost the
entire day.

In this commit, we introduce initial-queue-buffer-size, which defaults
to the current value of 8192. It can be set programmatically via
QueueConfiguration#setInitialQueueBufferSize(int).

Note that this must be a positive power of 2.
@joshb1050
Copy link
Contributor Author

@jbertram I agree, that makes sense. I have revised to initial-queue-buffer-size and changed usages, and also added additional context on when one might want to configure.

@joshb1050 joshb1050 requested a review from gemmellr August 2, 2024 21:56
@gemmellr
Copy link
Member

gemmellr commented Aug 6, 2024

LGTM

@asfgit asfgit closed this in 618738d Aug 14, 2024
@jbertram
Copy link
Contributor

@joshb1050, thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants