Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the MergingRun credit tracking strategy
The intention is to simplify things and make them more obviously correct in the presence of concurrency. This should have the bonus of making it easier to reliably determine leftover/excess supplied credits (which is something we want for supplying credits to trees of merging runs). The approach is to change the counters from three independent counters, to just two, which are modified together as a pair atomically. Previously we tracked the credits spent and unspent, and the steps performed. We did not explicitly keep track of credits that were in the process of being spent. Now we track spent and unspent (and not steps performed), but the spent credits includes those that are in the process of being spent. We keep these together in a single atomic variable, and so all operations on the pair are atomic. This makes the concurrency story much simpler because all credit tracking changes are atomic. We avoid having to track steps performed by accounting differently for the difference between credits used for merging and steps performed: we simply borrow more credits from the unspent pot, allowing the pot to become negative.
- Loading branch information