-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Diff transfer improvements #3645
Conversation
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.
Some of my comments on the current state.
a5dba1f
to
cd9c0f0
Compare
Resolved all previous comments, organized history, rebased on |
bd7ae82
to
ad44698
Compare
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.
Some comments (and ⛏️s) on a quick pass.
if clock_tag.clock_tick <= *tick { | ||
/// Remove a clock referenced by the clock tag from this recovery point, if the clock is | ||
/// *newer or equal* than the tick in the tag. | ||
pub fn remove_clock_if_newer_than_or_equal_to_tag(&mut self, tag: ClockTag) { |
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.
In my opinion names like this are a bit too explicit:
- 'clock's are obsolete because the only thing we manage is clocks
- 'tag' is obsolete because the parameter already clarifies this
This screams Java
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.
Kinda agree about "clock" part... but not about the "tag".
The problem with remove_if_newer_or_equal
is that it's not 100% clear if:
- we remove clock, if clock is newer than tag
- or we remove clock, if tag is newer than clock
It's more reasonable to read clock_map.remove_if_newer_or_equal(tag)
as "remove clock, if clock is newer than tag". But both cases are "reasonable enough". And so you have to go check documentation/code to verify what the actual behavior is. If we add _tag
at the end, it's clear just from the method name.
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 see how it is clear. The argument name does not change the fact, that you can read "if newer or equal" both ways. What are we comparing to what? clock > tag
or tag > clock
?
It does make more sense to read "left to right", e.g., clock > tag
, but, like, do you absolutely always do the most logical thing, or are you, like, human? :D
I mean, when you read this code for the first time, how can you be sure that it's clock > tag
? You have to go read the documentation/code to verify that it is indeed clock > tag
. Using newer_than_or_equal_to_tag
clarifies clock > tag
.
It is clear to you, because you've been working with it for the last two (three?) weeks.
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.
remove_ge_tag
?
The only reasonable assumption I can make about that is: we remove clocks, if greater or equal to the given tag.
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.
Or retain_old_clocks(tag)
with a comment describing the exact condition.
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.
remove_ge_tag
?
The only reasonable assumption I can make about that is: we remove clocks, if greater or equal to the given tag.
You still can read it both ways. Like, it literally reads as "remove greater or equal tag". Which is a lot like "remove if tag is greater of equal". Why are you so against the conjunctions? Just add remove_ge_to_tag
, and it's clear. Though, I'd still prefer fully verbose one. Not a huge fan of ge
and such.
Or
retain_old_clocks(tag)
with a comment describing the exact condition.
That's exactly what I don't want. I don't want to have to go read the comment. I want it to be obvious when you just read the method name. :/
|
||
channel_permit.send(UpdateSignal::Operation(OperationData { | ||
op_num: operation_id, | ||
operation: operation.operation, | ||
sender: callback_sender, | ||
wait, | ||
})); | ||
drop(wal_lock); |
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 put it here so we don't make the same mistake again 😄
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.
Ok, I kinda get your point now, but, IMO, it's not very effective and this part simply requires an explanation comment (with a lot of exclamation marks in it, maybe :D).
It's still super easy to just look at this code, see the drop
, think "WTF is this here for?" and just remove the drop
and refactor the wal_lock
away same way we did earlier.
If we add the comment, then it will explain that the drop
is intentional, and we have to hold the wal_lock
for the duration of send
... but at this point there's not much use in doing explicit drop
, IMO.
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.
If I see a drop
I always think: it must be there for a reason, lets be very careful about it.
Comments don't do the same to me while refactoring.
But anyway, fine with both.
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.
Hmmm...... I usually do as well, but in this case it's kinda obvious that it's the end of the scope, so I usually assume it's just a leftover from a refactoring or something.
@@ -154,10 +176,10 @@ impl RecoverableWal { | |||
/// If `None` - the remote WAL is already equal, and we don't have to send any records. | |||
/// If `Err` - no delta can be resolved. | |||
fn resolve_wal_delta( | |||
operations: impl DoubleEndedIterator<Item = (u64, Option<ClockTag>)>, |
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.
This one is potentially dangerous, because we say nothing about the order we expect.
7c92ecd
to
6afaa10
Compare
...and cleanup `clock_map` module documentation
...to `newest_observed_clocks` and `oldest_resolvable_clocks`
...to `newest_observed_clocks` and `oldest_resolvable_clocks`
...instead of WAL, to simplify unit-testing
1179325
to
c38fdfe
Compare
Ok, so the failing CI was my own fault (obviously, lol). It's fixed now. I think we can give it one last pass and merge. (Forgot to rename |
...to `newest_clocks` and `oldest_clocks`
Minor fixes/improvements/cleanups for diff transfer related code.
Tracked in: #3477
All Submissions:
dev
branch. Did you create your branch fromdev
?New Feature Submissions:
cargo +nightly fmt --all
command prior to submission?cargo clippy --all --all-features
command?Changes to Core Features: