Add native memory circuit breaker.#689
Conversation
Refactor all breakers from common to plugin. Add dynamic setting for native memory circuit breaker. Signed-off-by: Jing Zhang <jngz@amazon.com>
Codecov Report
@@ Coverage Diff @@
## 2.x #689 +/- ##
============================================
- Coverage 83.91% 83.50% -0.42%
- Complexity 1008 1021 +13
============================================
Files 93 99 +6
Lines 3662 3740 +78
Branches 343 344 +1
============================================
+ Hits 3073 3123 +50
- Misses 444 470 +26
- Partials 145 147 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Sicheng added BWC test, which test from 2.4.0, in 2.4.0, we don't have the native memory threshold setting |
| ); | ||
|
|
||
| public static final Setting<Integer> ML_COMMONS_NATIVE_MEM_THRESHOLD = Setting | ||
| .intSetting("plugins.ml_commons.native_mem_threshold", 90, 0, 100, Setting.Property.NodeScope, Setting.Property.Dynamic); |
There was a problem hiding this comment.
mem seems not so clear. how about change to
| .intSetting("plugins.ml_commons.native_mem_threshold", 90, 0, 100, Setting.Property.NodeScope, Setting.Property.Dynamic); | |
| .intSetting("plugins.ml_commons.native_memory_threshold", 90, 0, 100, Setting.Property.NodeScope, Setting.Property.Dynamic); |
There was a problem hiding this comment.
sure, will change it to memory.
| try { | ||
| return AccessController.doPrivileged((PrivilegedExceptionAction<Boolean>) () -> { | ||
| return (new File(diskDir).getFreeSpace()/1024/1024/1024) < getThreshold(); // in GB | ||
| return (new File(diskDir).getFreeSpace() / 1024 / 1024 / 1024) < getThreshold(); // in GB |
There was a problem hiding this comment.
minor: we can create constant for the disk threshold rather than recalculate for every request.
public static final long DEFAULT_FREE_DISK_SPACE_THRESHOLD = 5l * 1024 * 1024 * 1024;
There was a problem hiding this comment.
It's from original code not for this PR. Sure, I can add it.
There was a problem hiding this comment.
I prefer to add a contant only for 1024 * 1024 * 1024, as the original logic is using G as default unit.
| for (CircuitBreaker breaker : breakers.values()) { | ||
| if (breaker.isOpen()) { | ||
| return breaker.getName(); | ||
| return (ThresholdCircuitBreaker) breaker; |
There was a problem hiding this comment.
breaker class is CircuitBreaker, this line enforce it to ThresholdCircuitBreaker, seems not so extensible. If we have new child class of CircuitBreaker, this line will throw error.
Why need to change the return type from String to ThresholdCircuitBreaker?
There was a problem hiding this comment.
Want to get more information like the current threshold when breaker is triggered to help debug.
There was a problem hiding this comment.
I think we can add a warning log to help
Signed-off-by: Jing Zhang <jngz@amazon.com>
Signed-off-by: Jing Zhang <jngz@amazon.com>
| try { | ||
| return AccessController.doPrivileged((PrivilegedExceptionAction<Boolean>) () -> { | ||
| return (new File(diskDir).getFreeSpace()/1024/1024/1024) < getThreshold(); // in GB | ||
| return (new File(diskDir).getFreeSpace() / GB) < getThreshold(); // in GB |
There was a problem hiding this comment.
Can we just set threshold and compare directly without dividing GB for every request? Just like what you did for native memory breaker?
Signed-off-by: Jing Zhang <jngz@amazon.com>
| when(thresholdCircuitBreaker.getThreshold()).thenReturn(87); | ||
| expectedEx.expect(MLException.class); | ||
| expectedEx.expectMessage("Disk Circuit Breaker is open, please check your resources!"); | ||
| expectedEx.expectMessage("Disk Circuit Breaker is open, threshold is 87. Please check your resources!"); |
* Add native memory circuit breaker. Refactor all breakers from common to plugin. Add dynamic setting for native memory circuit breaker. Signed-off-by: Jing Zhang <jngz@amazon.com> * Address the comments 1. Signed-off-by: Jing Zhang <jngz@amazon.com> * Spotless changes. Signed-off-by: Jing Zhang <jngz@amazon.com> * Address the comments 2. Signed-off-by: Jing Zhang <jngz@amazon.com> Signed-off-by: Jing Zhang <jngz@amazon.com> (cherry picked from commit d809dd2)
* Add native memory circuit breaker. Refactor all breakers from common to plugin. Add dynamic setting for native memory circuit breaker. Signed-off-by: Jing Zhang <jngz@amazon.com> * Address the comments 1. Signed-off-by: Jing Zhang <jngz@amazon.com> * Spotless changes. Signed-off-by: Jing Zhang <jngz@amazon.com> * Address the comments 2. Signed-off-by: Jing Zhang <jngz@amazon.com> Signed-off-by: Jing Zhang <jngz@amazon.com> (cherry picked from commit d809dd2) Co-authored-by: Jing Zhang <jngz@amazon.com>
* Add native memory circuit breaker. Refactor all breakers from common to plugin. Add dynamic setting for native memory circuit breaker. Signed-off-by: Jing Zhang <jngz@amazon.com> * Address the comments 1. Signed-off-by: Jing Zhang <jngz@amazon.com> * Spotless changes. Signed-off-by: Jing Zhang <jngz@amazon.com> * Address the comments 2. Signed-off-by: Jing Zhang <jngz@amazon.com> Signed-off-by: Jing Zhang <jngz@amazon.com>
* Add native memory circuit breaker. Refactor all breakers from common to plugin. Add dynamic setting for native memory circuit breaker. Signed-off-by: Jing Zhang <jngz@amazon.com> * Address the comments 1. Signed-off-by: Jing Zhang <jngz@amazon.com> * Spotless changes. Signed-off-by: Jing Zhang <jngz@amazon.com> * Address the comments 2. Signed-off-by: Jing Zhang <jngz@amazon.com> Signed-off-by: Jing Zhang <jngz@amazon.com>
* Add native memory circuit breaker. Refactor all breakers from common to plugin. Add dynamic setting for native memory circuit breaker. Signed-off-by: Jing Zhang <jngz@amazon.com> * Address the comments 1. Signed-off-by: Jing Zhang <jngz@amazon.com> * Spotless changes. Signed-off-by: Jing Zhang <jngz@amazon.com> * Address the comments 2. Signed-off-by: Jing Zhang <jngz@amazon.com> Signed-off-by: Jing Zhang <jngz@amazon.com>
* Add native memory circuit breaker. Refactor all breakers from common to plugin. Add dynamic setting for native memory circuit breaker. * Address the comments 1. * Spotless changes. * Address the comments 2. Signed-off-by: Jing Zhang <jngz@amazon.com> Co-authored-by: Jing Zhang <jngz@amazon.com>
Add native memory circuit breaker.
Refactor all breakers from common to plugin.
Add dynamic setting for native memory circuit breaker.
Signed-off-by: Jing Zhang jngz@amazon.com
Description
Add native memory circuit breaker.
Refactor all breakers from common to plugin.
Add dynamic setting for native memory circuit breaker.
Issues Resolved
#648
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.