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

Only allocate models when circuit breaker is closed #74

Closed
wants to merge 1 commit into from

Conversation

kaituo
Copy link
Collaborator

@kaituo kaituo commented May 26, 2021

Note: since there are a lot of dependencies, I only list the main class and test code to save reviewers' time. The build will fail due to missing dependencies. I will use that PR just for review. will not merge it. Will have a big one in the end and merge once after all review PRs get approved. Now the code is missing unit tests. Will add unit tests, run performance tests, and fix bugs before the official release.

Description

Previously we may allocate memory when the circuit breaker is open but AD hasn’t used more than 10% of memory yet. This PR disallows any new model creation when the circuit breaker is open, which provides extra safety to prevent OOM.

This PR also differentiates isHostingAllowed and canAllocateReserved. Previously, both of them throw exceptions when allocation is not allowed. But most of the time it is fine to return false and let callers decide what to do if we cannot allocate. isHostingAllowed needs an exception thrown due to the special way the single-stream detector code is written (can be changed). This PR keeps the original exception thrown behavior of isHostingAllowed, but changes canAllocateReserved to return false instead.

Testing done:

  1. Tested an open circuit breaker prevented model creation.

Check List

  • [ Y ] Commits are signed per the DCO using --signoff

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.

Previously we may allocate memory when the circuit breaker is open but AD hasn’t used more than 10% of memory yet. This PR disallows any new model creation when the circuit breaker is open, which provides extra safety to prevent OOM.

This PR also differentiates isHostingAllowed and canAllocateReserved. Previously, both of them throw exceptions when allocation is not allowed. But most of the time it is fine to return false and let callers decide what to do if we cannot allocate. isHostingAllowed needs an exception thrown due to the special way the single-stream detector code is written (can be changed). This PR keeps the original exception thrown behavior of isHostingAllowed, but changes canAllocateReserved to return false instead.

Testing done:
1. Tested an open circuit breaker prevented model creation.
@kaituo kaituo requested review from ylwu-amzn and ohltyler May 26, 2021 19:52
Copy link
Collaborator

@ylwu-amzn ylwu-amzn left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -50,7 +51,7 @@

public enum Origin {
SINGLE_ENTITY_DETECTOR,
MULTI_ENTITY_DETECTOR,
HC_DETECTOR,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems this caused build failure. Make sure all places changed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure, will make sure that in the last PR with all of the code.

@kaituo kaituo closed this Jun 7, 2021
kaituo added a commit that referenced this pull request Jul 12, 2021
This PR is a conglomerate of the following PRs.

#60
#64
#65
#67
#68
#69
#70
#71
#74
#75
#76
#77
#78
#79
#82
#83
#84
#92
#94
#93
#95
kaituo#1
kaituo#2
kaituo#3
kaituo#4
kaituo#5
kaituo#6
kaituo#7
kaituo#8
kaituo#9
kaituo#10

This spreadsheet contains the mappings from files to PR number (bug fix in my AD fork and tests are not included):
https://gist.github.com/kaituo/9e1592c4ac4f2f449356cb93d0591167
ohltyler pushed a commit that referenced this pull request Sep 1, 2021
This PR is a conglomerate of the following PRs.

#60
#64
#65
#67
#68
#69
#70
#71
#74
#75
#76
#77
#78
#79
#82
#83
#84
#92
#94
#93
#95
kaituo#1
kaituo#2
kaituo#3
kaituo#4
kaituo#5
kaituo#6
kaituo#7
kaituo#8
kaituo#9
kaituo#10

This spreadsheet contains the mappings from files to PR number (bug fix in my AD fork and tests are not included):
https://gist.github.com/kaituo/9e1592c4ac4f2f449356cb93d0591167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants