From c38064952a8e8567cf24914c21addc581fb6cb25 Mon Sep 17 00:00:00 2001 From: Matthias Heinzel Date: Thu, 25 Jul 2024 12:45:19 +0200 Subject: [PATCH] prototype: supply 1.25 credits for tiering merges This is necessary to accomodate 5-way merges due to holding back runs that are too small. --- prototypes/ScheduledMerges.hs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/prototypes/ScheduledMerges.hs b/prototypes/ScheduledMerges.hs index 4f63f1d8e..cc747079d 100644 --- a/prototypes/ScheduledMerges.hs +++ b/prototypes/ScheduledMerges.hs @@ -464,20 +464,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 {