diff --git a/prototypes/ScheduledMerges.hs b/prototypes/ScheduledMerges.hs index 8e33893f1..0d42aab4a 100644 --- a/prototypes/ScheduledMerges.hs +++ b/prototypes/ScheduledMerges.hs @@ -466,20 +466,24 @@ bufferToRun = id supplyCredits :: Credit -> Levels s -> ST s () supplyCredits n ls = sequence_ - [ supplyMergeCredits (n * creditsForMerge mr) mr | Level mr _rs <- ls ] + [ supplyMergeCredits (ceiling (fromIntegral n * creditsForMerge mr)) mr + | Level mr _rs <- ls + ] -- | The general case (and thus worst case) of how many merge credits we need -- for a level. This is based on the merging policy at the level. -- -creditsForMerge :: MergingRun s -> Credit +creditsForMerge :: MergingRun s -> Float creditsForMerge SingleRun{} = 0 --- A levelling merge is 5x the cost of a tiering merge. --- That's because for levelling one of the runs as an input to the merge --- is the one levelling run which is (up to) 4x bigger than the others put --- together, so it's 1 + 4. -creditsForMerge (MergingRun MergePolicyLevelling _ _) = 5 -creditsForMerge (MergingRun MergePolicyTiering _ _) = 1 +-- A levelling merge has 1 input run and one resident run, which is (up to) 4x +-- bigger than the others. +-- It needs to be completed before another run comes in. +creditsForMerge (MergingRun MergePolicyLevelling _ _) = (1 + 4) / 1 + +-- A tiering merge has 5 runs at most (once could be held back to merged again) +-- and must be completed before the level is full (once 4 more runs come in). +creditsForMerge (MergingRun MergePolicyTiering _ _) = 5 / 4 type Event = EventAt EventDetail data EventAt e = EventAt {