-
Notifications
You must be signed in to change notification settings - Fork 9
Refactor pool logic #38
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
0b55e86 to
56fdac7
Compare
* Clean up AddLeafResult enum and add source() method to replace separate AddLeafResultSource enum * Move majority of logic for add_leaf_to_pool to mthods of PoolState. This will allow us to more easily change how the pooling works in a future PR (e.g., #33). * Remove pool_size parameter from configuration. It's never been useful to customize per log, so better to just make it a constant.
56fdac7 to
d3932b9
Compare
- Move Pool struct fields into PoolState, renaming by_hash to pending and done to pending_done. - Add take() and reset() functions to PoolState to mutate state - Rename pending_leaves -> pending_entries, sequence_pool -> sequence_entries
d3932b9 to
8ff3f8e
Compare
PendingLogEntry contains all of the fields of LogEntry except for the leaf index and timestamp.
8ff3f8e to
4568c22
Compare
Instead of using a Sender per pool of entries, allocate one Sender per pending entry. This is slightly less efficient as we're creating more channels, but gives much more flexibility for how we handle individual entries. More thorough benchmarking is needed, but from some quick tests there was no noticeable difference. This change also allows us to stop tracking the 'pool_index' of each log entry, and just transmit the final index on each entry's channel. This refactor will make it easier to only select a subset of the pending entries each time sequencing occurs, so we can try to keep the tree as a multiple of the full tile width (256), so we create fewer partial data and level-0 tiles (#33).
…ry to avoid clone
07b1cc1 to
ccc52f0
Compare
Add parameter specifying the maximum number of times a pending entry might be held back to prefer creating full tiles instead of partial tiles. fixes #33 This change required moving the logic to load the SequenceState from the sequence_entries function to the wrapping sequence function, and updating tests accordingly.
ccc52f0 to
2af4060
Compare
rozbb
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! Just some small notes
| // Flush all of the leftover entries if the oldest is before the cutoff. | ||
| let flush_oldest = self.holds >= max_pending_entry_holds; | ||
|
|
||
| if leftover == 0 || flush_oldest { |
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.
So if flush_oldest is triggered when there's 1.5 tiles pending, we'll publish 1.5 files? Why not just publish a full one and hold back the half?
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.
Yep, that's what will currently happen, unless max_pending_entry_holds = 0, in which case we always flush the oldest (which is the previous behavior before this PR).
This test demonstrates that behavior: https://github.com/cloudflare/azul/pull/38/files#diff-04abdf856a7b917bbd1ca592d4f3026c5f36bd03afcc4928103cf5a58143670bR1509.
This PR contains quite a bit of refactoring of the pool logic in order to address #33. The most significant change is using a separate https://docs.rs/tokio/latest/tokio/sync/watch/index.html
{Sender, Receiver}pair per entry instead of per "pool" of entries. This gives us the flexibility to break up pools of pending entries so we can hold back some entries when sequencing to try to prefer creating full tiles.The commits can be reviewed independently and each have more detailed commit messages, although some of the commits remove or refactor code added in previous commits (e.g., the
Poolstruct).