-
Notifications
You must be signed in to change notification settings - Fork 661
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
SOLR-17150: Create MemAllowedLimit #2708
Conversation
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.
Lack of doc leaves me with some doubt as to the efficacy of my review. Biggest suggestion is to add Javadoc and clarify the asciidoc
solr/solr-ref-guide/modules/query-guide/pages/common-query-parameters.adoc
Outdated
Show resolved
Hide resolved
solr/solr-ref-guide/modules/query-guide/pages/common-query-parameters.adoc
Outdated
Show resolved
Hide resolved
* Enforces a memory-based limit on a given SolrQueryRequest, as specified by the {@code memAllowed} | ||
* query parameter. | ||
* | ||
* <p>This class tracks per-thread memory allocations using its own ThreadLocal. It records the |
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.
"per-thread memory allocations during a request using it's own Thread Local."
I think that phrase would give the gist without the reader needing to parse the following logic.
initAndGetCurrentAllocatedBytes(); | ||
} | ||
|
||
private long initAndGetCurrentAllocatedBytes() { |
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.
Methods called in constructors should be final.
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 method is private, nothing can override it.
@@ -99,9 +136,8 @@ public boolean shouldExit() { | |||
} | |||
|
|||
try { | |||
long currentAllocatedBytes = (Long) GET_BYTES_METHOD.invoke(threadBean); | |||
long currentAllocatedBytes = initAndGetCurrentAllocatedBytes(); |
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 feel like you should have an init()
method (or just code in the constructor), and a getCurrentAllocatedBytes()
method and thus avoid all init logic in subsequent calls? I believe Java guarantees that nothing calls methods on an object until the constructor completes.
This is a refreshed PR using the latest QueryLimit APIs and a thread-safe accumulation of value, similar to the approach in
CpuAllowedLimit
. However, since that class uses a thread-local managed byThreadCpuTimer
this implementation adds its own thread-local.