Skip to content

Commit 184809a

Browse files
committed
MergeSchedule: update maxMergeDebt to be in line with maxPhysicalDebt
1 parent 19b531f commit 184809a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Database/LSMTree/Internal/MergeSchedule.hs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,8 @@ supplyCredits conf deposit levels =
959959
-- supplyCreditsIncomingRun could easily return the supplied credits
960960
-- before & after, which may be useful for tracing.
961961

962+
-- | See 'maxPhysicalDebt' in 'newLevelMerge' in the 'ScheduledMerges'
963+
-- prototype.
962964
maxMergeDebt :: TableConfig -> MergePolicyForLevel -> LevelNo -> MergeDebt
963965
maxMergeDebt TableConfig {
964966
confWriteBufferAlloc = AllocNumEntries (NumEntries -> bufferSize),
@@ -968,16 +970,13 @@ maxMergeDebt TableConfig {
968970
case mergePolicy of
969971
LevelLevelling ->
970972
MergeDebt . MergeCredits $
971-
sizeRatio * maxRunSizeTiering sizeRatio bufferSize (pred ln)
973+
sizeRatio * maxRunSizeTiering sizeRatio bufferSize ln
972974
+ maxRunSizeLevelling sizeRatio bufferSize ln
973975

974976
LevelTiering ->
975977
MergeDebt . MergeCredits $
976-
maxRuns * maxRunSizeTiering sizeRatio bufferSize (pred ln)
977-
where
978-
-- We can hold back underfull runs, so sometimes the are n+1 runs,
979-
-- rather than the typical n at a tiering level (n = LSM size ratio).
980-
maxRuns = sizeRatio + 1
978+
sizeRatio * maxRunSizeTiering sizeRatio bufferSize ln
979+
+ maxRunSizeTiering sizeRatio bufferSize (pred ln)
981980

982981
-- | The nominal debt equals the minimum of credits we will supply before we
983982
-- expect the merge to complete. This is the same as the number of updates

0 commit comments

Comments
 (0)