-
-
Notifications
You must be signed in to change notification settings - Fork 428
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
Clean up Mutex/Instant::now() use for send message error logging #2158
Conversation
This adds abstraction to simple code and introduces some complex cfg gates. Can you elaborate on the motivation? |
Sure. If you don't have/use logging, this saves a little space in UdpSocketState, reduces some code duplication, and skips an Instant::now(). Overall it also makes it easier to audit for usage of Instant::now() in quinn-proto/quinn-udp (trying to stay I/O-agnostic). |
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.
Sure. If you don't have/use logging, this saves a little space in UdpSocketState, reduces some code duplication, and skips an Instant::now(). Overall it also makes it easier to audit for usage of Instant::now() in quinn-proto/quinn-udp (trying to stay I/O-agnostic).
Storing a Mutex<Instant>
per UDP socket and calling Instant::now()
both seem trivial in cost. Reducing code duplication at the cost of net-increasing lines of code and adding cfg-gated type aliases seems like a net loss in terms of code simplicity.
I'm in favor of locking down usage of Instant::now()
, but perhaps it would be better to start with more clearly articulating what your target use case is specifically and work from there to see how we can accommodate it?
If you want to go here (I hope this is motivated by actual benchmarks rather than "premature" optimization efforts), I don't think this is the right way to go. Instead, I'd extract the error code into an |
Using an ErrorSink is a great idiom, thanks, I switched to that. Overall it's less about perf and more about consistency. Particularly quinn-proto but also, as far as I can tell, quinn-udp both appear to be built to avoid calling Instant::now() in business code to leave that part of syscall/IO work to the user. I did a review of those two crates and saw one use of it in business code (removed in #2157), many usages of it in tests (which is fine), and this use in logging. I figured that reducing the places where it's acceptably called would make it easier to audit these usages. That it spares some bytes and avoids a syscall or two at runtime is a nice but extremely minor value add. |
Well, I think you're overindexing on a particular aspect of a design goal - our design goal for quinn-proto was that it would be deterministic (that is, all function call outputs can be fully determined from function call inputs). That means there should not be As is, I don't think we should merge this changes. If you can clean up the commit history (the 2nd or 3rd time I asked...) to have one clean commit that refactors the current implementation to have a better abstraction boundary, and then a second commit that makes the implementation optional, we can consider whether that trade-off makes sense here. |
Sorry, I'm used to squashing before merging a PR, not beforehand. I'm not sure what is being asked for here but I can look it up and try my best. The current state of the files changed in the PR should be accurate to what I'd like to merge. Do you want me to close this and open a new clean PR?
Is the abstraction boundary you're asking for here the ErrorSink or something else? FWIW I'm not terribly committed to this so I'm happy to just close this if it isn't a decent change. |
dcdcb53
to
34eb32a
Compare
I think that cleaned it up as requested? |
f12b4c6
to
575468c
Compare
575468c
to
c06a86a
Compare
…to last-send-error
Clean up Mutex/Instant::now() use for send message error logging Reverting incorporated change? Eliminating an Instant::now() in BBR bandwidth estimation code This was the only case where `Instant::now()` is used in quinn-proto or quinn-udp for anything other than tests or rate-limiting logging. Making this change to keep these two crates more IO-agnostic.
…to last-send-error
I have unbelievably messed up this branch trying to squash it (I have no idea what I'm doing here) and nobody wants this change so I'm just going to close it. |
No description provided.