-
Notifications
You must be signed in to change notification settings - Fork 9
Do merge work in batches #435
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
Conversation
9e80b61 to
0fdf091
Compare
bb95545 to
27107f3
Compare
0d7efcb to
5309353
Compare
mheinzel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, nice documentation! Just a few points to discuss.
0d7e461 to
4837e51
Compare
mheinzel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but some additional questions.
mheinzel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the naming can be clarified a bit, but should work!
c5cc13a to
78d6413
Compare
mheinzel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is alright now. Just some small tweaks.
mheinzel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think the scaled/unscaled credit distinction could be a little clearer in some places, but this will improve as soon as we move MergingRun into its own module. In there, we will always consider scaled credits. In MergeSchedule we talk about unscaled credits, only converting at the end to call MergingRun.supplyMergeCredits.
|
|
||
| data SnapMergingRun = | ||
| SnapMergingRun !MergePolicyForLevel !NumRuns !SnapMergingRunState | ||
| SnapMergingRun !MergePolicyForLevel !NumRuns !NumEntries !UnspentCredits !MergeKnownCompleted !SnapMergingRunState |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to snapshot the MergeKnownCompleted? It's like a cache, we can just reconstruct it from the SnapMergingRunState.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've thought about this as well, and I think both with and without storing it here works. It just means we can skip a bit of work now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd rather keep the snapshot format lean. This would just mean two more lines of code in opening a snapshot and even save one when creating it I think, or are you referring to some other work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your point, but I'm going to change this code later anyway, so I'll keep it as is and follow up with refactorings
78d6413 to
ea34fe1
Compare
mheinzel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some previous comments are still unresolved, but no blockers.
| mergeKnownCompleted <- readMutVar mergeKnownCompletedVar | ||
| -- The merge is not guaranteed to be complete. | ||
| when (mergeKnownCompleted == MergeMaybeCompleted) $ do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think using the cache matters much here (this only happens once per merge). To keep complexity low, I would only use it on the hot path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd argue that it decreases complexity: the cached value has a simple correctness argument, so checking it here means we can skip the more complex bit of trying to finish a (maybe) incomplete merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, we need to have the branch that finishes an incomplete merge either way. So this just adds an additional branch. But I don't mind much, all good.
This is done to make it clear that there is a difference between progressing the merge until there are no more inputs to merge (`Done`), and converting the merge into an output run (`Complete`).
See `Note [Credits]`
0f1b0f9 to
9c4dd1f
Compare
This is a follow-up to #426
The best description of the approach can be found in the code, in the GHC-style note
Note [Credits]