Skip to content

Commit

Permalink
CA-396124: amend criteria under which the garbage collector aborts
Browse files Browse the repository at this point in the history
1. On the first iteration do not assess any of the failure criteria
2. Allow for two "grace" iterations, where the size is permitted to
grow and only consume those if the current size has grown more than
permitted from minimum achieved.

Signed-off-by: Mark Syms <mark.syms@cloud.com>
  • Loading branch information
MarkSymsCtx committed Aug 21, 2024
1 parent 2979937 commit 0837303
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
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

0 comments on commit 0837303

Please sign in to comment.