-
Notifications
You must be signed in to change notification settings - Fork 19
Issue 6438 - Method to manage memory use in StateStoreProvider #6466
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
Conversation
| "be used in cases where the state store cache is the main use of memory, currently only in a " + | ||
| "state store committer on the EC2 platform. This affects how many state stores can be cached in " + | ||
| "memory.") | ||
| .defaultValue("1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 1% an realistic value here for default?
(Know it was previously this, just checking logic is sound given we are making changes in this area)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could remove the percentage property. When I was building this feature out I started off by evicting state stores to keep a certain percentage of the heap available. However, I switched to a fixed limit as I was testing and found that everything continued to work with <1% and it felt awkward setting the property to smaller percentages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
java/core/src/main/java/sleeper/core/statestore/StateStoreProvider.java
Outdated
Show resolved
Hide resolved
|
|
||
| // Try to make sure there is going to be enough heap space available to process these commits | ||
| ensureEnoughHeapSpaceAvailable(messagesByTableId.keySet()); | ||
| while (!stateStoreProvider.ensureEnoughHeapSpaceAvailable(messagesByTableId.keySet())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting java.lang.NullPointerException: Cannot invoke "sleeper.core.statestore.StateStoreProvider.ensureEnoughHeapSpaceAvailable(java.util.Collection)" because "this.stateStoreProvider" is null. It becomes not null when we receive our first message from the SQS queue, but if no messages are immediately available then this error is thrown. Add stateStoreProvider != null to while or wrap with an if?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reproduced that in MultiThreadedStateStoreCommitterLocalStackIT and fixed it, thanks.
| "be used in cases where the state store cache is the main use of memory, currently only in a " + | ||
| "state store committer on the EC2 platform. This affects how many state stores can be cached in " + | ||
| "memory.") | ||
| .defaultValue("1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could remove the percentage property. When I was building this feature out I started off by evicting state stores to keep a certain percentage of the heap available. However, I switched to a fixed limit as I was testing and found that everything continued to work with <1% and it felt awkward setting the property to smaller percentages.
...e-committer/src/main/java/sleeper/statestore/committer/MultiThreadedStateStoreCommitter.java
Show resolved
Hide resolved
| LoggedDuration.withShortOutput(startedAt, Instant.now()), | ||
| LoggedDuration.withShortOutput(lastReceivedCommitsAt, Instant.now())); | ||
|
|
||
| lastReceivedCommitsAt = Instant.now(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrectly getting set when no commits have been taken off the queue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that, I've reverted this change.
| } | ||
|
|
||
| @Override | ||
| public final String toString() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you've mentioned in the docs for this class, the field names are a bit complicated to understand. This implementation of toString results in logs that look like this:
[main] core.statestore.StateStoreProvider DEBUG - Keeping 100 MB free. Found memory use: JvmMemoryUse{totalMemory='80 MB', freeMemory='46 MB', maxMemory='6 GB'}
This makes it look like there isn't enough memory available, but there is. Should the loggers reference .availableMemory() instead of relying on .toString() to make the log output clearer? or should availableMemory be included in the toString() output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've adjusted the toString method and added unit tests for it.
Make sure you have checked all steps below.
Issue
Feature". Note that before an issue is finished, you can still make a pull request by raising a separate issue
for your progress.
Tests
Documentation
separate issue for that below.