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

CA-396124: amend criteria under which the garbage collector aborts #704

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions drivers/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,7 @@ def _coalesce(self, vdi):
self.deleteVDI(vdi)

class CoalesceTracker:
GRACE_ITERATIONS = 1
GRACE_ITERATIONS = 2
MAX_ITERATIONS_NO_PROGRESS = 3
MAX_ITERATIONS = 10
MAX_INCREASE_FROM_MINIMUM = 1.2
Expand All @@ -1973,10 +1973,9 @@ def __init__(self, sr):
self.startSize = None
self.finishSize = None
self.sr = sr
self.grace_remaining = self.GRACE_ITERATIONS

def abortCoalesce(self, prevSize, curSize):
res = False

self.its += 1
self.history.append(self.HISTORY_STRING.format(its=self.its,
initSize=prevSize,
Expand All @@ -1993,33 +1992,38 @@ def abortCoalesce(self, prevSize, curSize):
if prevSize < self.minSize:
self.minSize = prevSize

if self.its == 1:
# Skip evaluating conditions on first iteration
return False

if prevSize < curSize:
self.itsNoProgress += 1
Util.log("No progress, attempt:"
" {attempt}".format(attempt=self.itsNoProgress))
util.fistpoint.activate("cleanup_tracker_no_progress", self.sr.uuid)

if (not res) and (self.its > self.MAX_ITERATIONS):
if self.its > self.MAX_ITERATIONS:
max = self.MAX_ITERATIONS
self.reason = \
"Max iterations ({max}) exceeded".format(max=max)
res = True
return True

if (not res) and (self.itsNoProgress >
self.MAX_ITERATIONS_NO_PROGRESS):
if self.itsNoProgress > self.MAX_ITERATIONS_NO_PROGRESS:
max = self.MAX_ITERATIONS_NO_PROGRESS
self.reason = \
"No progress made for {max} iterations".format(max=max)
res = True
return True

maxSizeFromMin = self.MAX_INCREASE_FROM_MINIMUM * self.minSize
if (self.its > self.GRACE_ITERATIONS and
(not res) and (curSize > maxSizeFromMin)):
self.reason = "Unexpected bump in size," \
" compared to minimum achieved"
res = True
if curSize > maxSizeFromMin:
self.grace_remaining -= 1
if self.grace_remaining == 0:
self.reason = "Unexpected bump in size," \
" compared to minimum achieved"

return True

return res
return False

def printReasoning(self):
Util.log("Aborted coalesce")
Expand Down
10 changes: 7 additions & 3 deletions tests/test_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,14 +1299,17 @@ def test_leafCoalesceTracker(self):
expectedHistory = [
"Iteration: 1 -- Initial size 100 --> Final size 100",
"Iteration: 2 -- Initial size 100 --> Final size 121",
"Iteration: 3 -- Initial size 100 --> Final size 141",
]
expectedReason = "Unexpected bump in size," \
" compared to minimum achieved"
res = tracker.abortCoalesce(100, 100)
self.assertFalse(res)
res = tracker.abortCoalesce(100, 121)
self.assertFalse(res)
res = tracker.abortCoalesce(100, 141)
self.autopsyTracker(tracker, res, expectedHistory,
expectedReason, 100, 121, 100)
expectedReason, 100, 141, 100)

def test_leafCoaleesceTracker_too_many_iterations(self):
sr = create_cleanup_sr(self.xapi_mock)
Expand Down Expand Up @@ -1343,10 +1346,11 @@ def test_leafCoalesceTracker_getting_bigger(self):
"Iteration: 1 -- Initial size 100 --> Final size 101",
"Iteration: 2 -- Initial size 100 --> Final size 101",
"Iteration: 3 -- Initial size 100 --> Final size 101",
"Iteration: 4 -- Initial size 100 --> Final size 101"
"Iteration: 4 -- Initial size 100 --> Final size 101",
"Iteration: 5 -- Initial size 100 --> Final size 101"
]
expectedReason = "No progress made for 3 iterations"
self.exerciseTracker(tracker, 100, 101, 3, expectedHistory,
self.exerciseTracker(tracker, 100, 101, 4, expectedHistory,
expectedReason, 100, 101, 100)

def runAbortable(self, func, ret, ns, abortTest, pollInterval, timeOut):
Expand Down
Loading