Skip to content
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

Pluggable congestion control #759

Merged
merged 1 commit into from
May 12, 2020
Merged

Pluggable congestion control #759

merged 1 commit into from
May 12, 2020

Conversation

Ralith
Copy link
Collaborator

@Ralith Ralith commented May 10, 2020

As discussed in #693. Draft until the abstractness of the interface has been validated by the addition of at least one other controller (probably CUBIC/HyStart++).

@Ralith Ralith force-pushed the pluggable-cc branch 4 times, most recently from 7c7cf6d to cbb56b6 Compare May 10, 2020 19:00
@Ralith Ralith marked this pull request as ready for review May 10, 2020 19:00
@Ralith Ralith force-pushed the pluggable-cc branch 2 times, most recently from 33e5c5a to 8a108ea Compare May 10, 2020 19:25
@codecov
Copy link

codecov bot commented May 10, 2020

Codecov Report

Merging #759 into master will decrease coverage by 0.16%.
The diff coverage is 32.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #759      +/-   ##
==========================================
- Coverage   70.90%   70.74%   -0.17%     
==========================================
  Files          73       74       +1     
  Lines       12917    12960      +43     
==========================================
+ Hits         9159     9168       +9     
- Misses       3758     3792      +34     
Impacted Files Coverage Δ
interop/src/main.rs 0.00% <ø> (ø)
quinn-proto/src/lib.rs 83.33% <ø> (ø)
quinn-proto/src/config.rs 28.73% <4.34%> (-2.13%) ⬇️
quinn-proto/src/congestion/new_reno.rs 39.02% <39.02%> (ø)
quinn-proto/src/connection/mod.rs 79.81% <52.63%> (+0.07%) ⬆️
quinn-proto/src/packet.rs 86.42% <0.00%> (-0.24%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17d9788...f065a5a. Read the comment docs.

@djc
Copy link
Member

djc commented May 12, 2020

I think I'm okay with the config Arc now. Can you sketch what your explicit trait alternative for the factory thing would look like? I can't quite wrap my head around what the constraints are.

(Otherwise, things look pretty good to me, though I'll do a final pass once we figure out the factory thing.)

@Ralith
Copy link
Collaborator Author

Ralith commented May 12, 2020

The explicit trait approach:

pub trait CongestionControllerFactory {
    fn new_controller(&self) -> Box<dyn CongestionController>;
}
// ...
impl CongestionControllerFactory for Arc<NewRenoConfig> {
    fn new_controller(&self) -> Box<dyn CongestionController> {
        Box::new(NewReno::new(self.clone(), Instant::now()))
    }
}

In use:

config.congestion_controller_factory(Arc::new(config));

@djc
Copy link
Member

djc commented May 12, 2020

How would the maybe_rebinding case look for that? I think it'd need a separate impl? How do you feel about current approach vs explicit trait?

@Ralith
Copy link
Collaborator Author

Ralith commented May 12, 2020

(self.config.congestion_controller_factory)() would be replaced with self.config.congestion_controller_factory.new_controller(); no other changes. A trait with one method that takes &self is always algebraically equivalent to an analogous Fn.

Between the two, I'm leaning towards the explicit trait right now, because config.congestion_controller_factory(Arc::new(config)); seems like considerably less ceremony than config.congestion_controller_factory(|| Box::new(NewReno::new(config, Instant::now()))). It's more boilerplate if you want to invoke complicated custom logic, but that seems like an extremely niche case.

@djc
Copy link
Member

djc commented May 12, 2020

Cool, I think I agree.

@Ralith
Copy link
Collaborator Author

Ralith commented May 12, 2020

Updated with an explicit factory trait. I also refactored things to make the congestion module public rather than reexporting its contents, to ease discoverability of different algorithms we add in the future, and to limit growth of clutter in the root namespace.

@Ralith Ralith force-pushed the pluggable-cc branch 2 times, most recently from fad6fea to dc01790 Compare May 12, 2020 19:35
Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, reviewed the trait in a little more detail.

Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!

@djc djc merged commit 790546a into master May 12, 2020
@delete-merged-branch delete-merged-branch bot deleted the pluggable-cc branch May 12, 2020 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants