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

#2057: Shuffle outgoing transport parameters. #2066

Merged
merged 2 commits into from
Nov 28, 2024

Conversation

mstyura
Copy link
Contributor

@mstyura mstyura commented Nov 24, 2024

I propose to remember the order in which write of the params should be performed when TransportParameters are crated. Then this order is used to write to wire format.
PR currently split into two commits:

  1. Do the permutation using hard-coded IDs of prams;
  2. Some refactoring to store the IDs into enum.

@mstyura mstyura changed the title Shuffle outgoing transport parameters. #2057: Shuffle outgoing transport parameters. Nov 24, 2024
@djc
Copy link
Member

djc commented Nov 25, 2024

I propose to remember the order in which write of the params should be performed when TransportParameters are crated. Then this order is used to write to wire format.

Why do you want to store the order? That seems largely unrelated to the stated goal of this PR to shuffle transport params.

I think the commit introducing an enum should come first. Suggest extracting the macro from its current location in a separate commit so that it can get only the necessary modifications in place in the further commits.

@mstyura mstyura force-pushed the gh-2057-premutation branch from 4ecbb6c to 1f78a7b Compare November 25, 2024 09:56
@mstyura
Copy link
Contributor Author

mstyura commented Nov 25, 2024

Why do you want to store the order? That seems largely unrelated to the stated goal of this PR to shuffle transport params.

@djc maybe I'm missing something, but inside TransportParameters::write I don't have access to random generator passed form Connection to perform shuffle at that time and in my previous MR it was suggested to not to use rand::thread_rng() directly. So the solution was to store the write order inside constructor where I have an access to random generator injected from Connection and use this order during write. Let me know if you think this could be done differently.

I think the commit introducing an enum should come first. Suggest extracting the macro from its current location in a separate commit so that it can get only the necessary modifications in place in the further commits.

Do you mean only re-order commits in this MR or I should better to put refactoring related to TransportParameterId into separate PR and wait until it merged and update this MR with only shuffling implemented?

@djc
Copy link
Member

djc commented Nov 25, 2024

Why do you want to store the order? That seems largely unrelated to the stated goal of this PR to shuffle transport params.

@djc maybe I'm missing something, but inside TransportParameters::write I don't have access to random generator passed form Connection to perform shuffle at that time and in my previous MR it was suggested to not to use rand::thread_rng() directly. So the solution was to store the write order inside constructor where I have an access to random generator injected from Connection and use this order during write. Let me know if you think this could be done differently.

Ah, makes sense -- sorry for the noise!

I think the commit introducing an enum should come first. Suggest extracting the macro from its current location in a separate commit so that it can get only the necessary modifications in place in the further commits.

Do you mean only re-order commits in this MR or I should better to put refactoring related to TransportParameterId into separate PR and wait until it merged and update this MR with only shuffling implemented?

Reordering commits in this PR should be okay.

@mstyura mstyura force-pushed the gh-2057-premutation branch from 1f78a7b to d169653 Compare November 26, 2024 11:04
@mstyura
Copy link
Contributor Author

mstyura commented Nov 26, 2024

Reordering commits in this PR should be okay.

Re-ordered commits and hopefully a bit enhanced implementation by allowing == between TransportParameterId and u64 to avoid several usages as u64 casts inside guard of match expression.

Ah, makes sense -- sorry for the noise!

Also a bit changed implementation of reordering. Instead of storing all transport parameter IDs inside write_order array inside TransportPrameters which occupied 21 * u64 = 168 bytes spaces in struct I stored 21 * u8 values which treated as indices of SUPPORTED_TRANSPORT_PARAMETERS array.

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.

This is looking pretty good!

@mstyura mstyura force-pushed the gh-2057-premutation branch 3 times, most recently from f050208 to 2e3ef27 Compare November 27, 2024 11:55
@mstyura mstyura force-pushed the gh-2057-premutation branch 4 times, most recently from 3c7e8e2 to 1b593cb Compare November 27, 2024 21:24
@mstyura mstyura force-pushed the gh-2057-premutation branch from 1b593cb to 5f8b406 Compare November 27, 2024 22:21
Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

Thanks!

@djc djc added this pull request to the merge queue Nov 28, 2024
Merged via the queue into quinn-rs:main with commit f188909 Nov 28, 2024
17 checks passed
@mstyura
Copy link
Contributor Author

mstyura commented Nov 28, 2024

@djc, @Ralith thank you very much for review, feedback and patience! And accepting this change!

@Ralith
Copy link
Collaborator

Ralith commented Nov 29, 2024

Thanks for your contribution! I've been specifically wanting this for a while.

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.

3 participants