-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update sequence impl to tune controller memory consumption #2387
Update sequence impl to tune controller memory consumption #2387
Conversation
828162f
to
c061fe0
Compare
@tardieu @markusthoemmes @ioana-blue might any of you want to review this? |
c061fe0
to
792d3f2
Compare
@starpit as I noted on slack, we should have unit tests for the new/refactored code. It's far more testable now and we can get good coverage. If you don't have bandwidth for this, I will work on that tomorrow. |
792d3f2
to
dd99793
Compare
…gs in heap. switch to scheduleOnce+weakrefs for timeout handling in SequenceActions switch SequenceAccounting to store array of ActivationId rather than array of String -- cheaper in memory use better (non-dragging) impl of withTimeout use a getAndSet(null) pattern to avoid two copies of responses being alive simultaneously
Remove pre-allocated array and use mutable array buffer. Terminate the fold when shortcuirting. Use copy constructor for fail. Remove promise. Dusting of tests.
239b6b9
to
62d65d1
Compare
62d65d1
to
8c2175c
Compare
8a41fdd
to
f97f892
Compare
.map(currentMax => Some(Math.max(prevMax, currentMax))) | ||
.getOrElse(prevMemoryLimit) | ||
}.getOrElse(newMemoryLimit) | ||
} |
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 this the same as:
(prevMemoryLimit ++ newMemoryLimit).reduceOption(Math.max)
?
protected[actions] case class SequenceAccounting( | ||
atomicActionCnt: Int, | ||
previousResponse: AtomicReference[ActivationResponse], | ||
logs: mutable.ArrayBuffer[ActivationId], |
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.
Do we rely on this being an ArrayBuffer anywhere, or could it aswell be the more general Buffer
?
/** The previous activation failed (this is used when there is no activation record or an internal error. */ | ||
def fail(failureResponse: ActivationResponse, activationId: Option[ActivationId]) = { | ||
require(!failureResponse.isSuccess) | ||
activationId.foreach(logs += _) |
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.
logs.appendAll(activationId)
?
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.
LGTM
- switch to scheduleOnce+weakrefs for timeout handling in SequenceActions - switch SequenceAccounting to store array of ActivationId rather than array of String -- cheaper in memory - use better (non-dragging) impl of withTimeout - use a getAndSet(null) pattern to avoid two copies of responses being alive simultaneously - refactor top level sequence scheduler to eliminate promises
- switch to scheduleOnce+weakrefs for timeout handling in SequenceActions - switch SequenceAccounting to store array of ActivationId rather than array of String -- cheaper in memory - use better (non-dragging) impl of withTimeout - use a getAndSet(null) pattern to avoid two copies of responses being alive simultaneously - refactor top level sequence scheduler to eliminate promises
- switch to scheduleOnce+weakrefs for timeout handling in SequenceActions - switch SequenceAccounting to store array of ActivationId rather than array of String -- cheaper in memory - use better (non-dragging) impl of withTimeout - use a getAndSet(null) pattern to avoid two copies of responses being alive simultaneously - refactor top level sequence scheduler to eliminate promises
- switch to scheduleOnce+weakrefs for timeout handling in SequenceActions - switch SequenceAccounting to store array of ActivationId rather than array of String -- cheaper in memory - use better (non-dragging) impl of withTimeout - use a getAndSet(null) pattern to avoid two copies of responses being alive simultaneously - refactor top level sequence scheduler to eliminate promises
- switch to scheduleOnce+weakrefs for timeout handling in SequenceActions - switch SequenceAccounting to store array of ActivationId rather than array of String -- cheaper in memory - use better (non-dragging) impl of withTimeout - use a getAndSet(null) pattern to avoid two copies of responses being alive simultaneously - refactor top level sequence scheduler to eliminate promises
- switch to scheduleOnce+weakrefs for timeout handling in SequenceActions - switch SequenceAccounting to store array of ActivationId rather than array of String -- cheaper in memory - use better (non-dragging) impl of withTimeout - use a getAndSet(null) pattern to avoid two copies of responses being alive simultaneously - refactor top level sequence scheduler to eliminate promises
- switch to scheduleOnce+weakrefs for timeout handling in SequenceActions - switch SequenceAccounting to store array of ActivationId rather than array of String -- cheaper in memory - use better (non-dragging) impl of withTimeout - use a getAndSet(null) pattern to avoid two copies of responses being alive simultaneously - refactor top level sequence scheduler to eliminate promises
- switch to scheduleOnce+weakrefs for timeout handling in SequenceActions - switch SequenceAccounting to store array of ActivationId rather than array of String -- cheaper in memory - use better (non-dragging) impl of withTimeout - use a getAndSet(null) pattern to avoid two copies of responses being alive simultaneously - refactor top level sequence scheduler to eliminate promises
- switch to scheduleOnce+weakrefs for timeout handling in SequenceActions - switch SequenceAccounting to store array of ActivationId rather than array of String -- cheaper in memory - use better (non-dragging) impl of withTimeout - use a getAndSet(null) pattern to avoid two copies of responses being alive simultaneously - refactor top level sequence scheduler to eliminate promises
- switch to scheduleOnce+weakrefs for timeout handling in SequenceActions - switch SequenceAccounting to store array of ActivationId rather than array of String -- cheaper in memory - use better (non-dragging) impl of withTimeout - use a getAndSet(null) pattern to avoid two copies of responses being alive simultaneously - refactor top level sequence scheduler to eliminate promises
- switch to scheduleOnce+weakrefs for timeout handling in SequenceActions - switch SequenceAccounting to store array of ActivationId rather than array of String -- cheaper in memory - use better (non-dragging) impl of withTimeout - use a getAndSet(null) pattern to avoid two copies of responses being alive simultaneously - refactor top level sequence scheduler to eliminate promises
Fixes #2386
This PR changes SequenceActions to use foldLeft rather than scanLeft. The change requires the introduction of a new accumulator data structure, to maintain the accumulated state for the reduction. The accumulated state includes an array of handles to logs (for the components), the cumulative duration, and a few other bits needed for creation of the final sequence activation record.
This fix also patches a closely related memory drag, caused by the way timeouts of sequence invocations are handled. See #2294 which patches other parts of the controller for the same kind of timeout drag. This patch needs to be a little different, due to the complex way the SequenceActions impl uses nested Promises.
PG3 625 🔵