-
Notifications
You must be signed in to change notification settings - Fork 124
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
perf: don't allocate in UDP send & recv path #2093
Draft
mxinden
wants to merge
89
commits into
mozilla:main
Choose a base branch
from
mxinden:send-recv-no-alloc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
89 commits
Select commit
Hold shift + click to select a range
5d847ee
perf: don't allocate in UDP send & recv path
mxinden b334e84
Merge Encoder impl blocks
mxinden 2db53a2
Fix tests
mxinden 9fef795
clippy
mxinden 995c499
fix some, ignore some
mxinden 1c653de
Always run bench
mxinden c05bc64
First process_input then process_http3
mxinden 08eba9d
Revert "fix some, ignore some"
mxinden ae112c8
Remove process_multiple_input
mxinden 828da75
Cleanup classic process fn delegating to process_x_2
mxinden dfa33b2
Consolidate process functions
mxinden 763b391
Rename process to process_alloc
mxinden 8dee7b3
Rename process_into to process
mxinden 5576875
New TODO
mxinden b9457bb
Copy only for Datagram &[u8]
mxinden 94d1a68
Fix more tests
mxinden e2d1452
remove all public process_output
mxinden 2e2a76e
Merge branch 'main' of https://github.com/mozilla/neqo into send-recv…
mxinden 1947d33
Remove process_2
mxinden 8ea56b2
Intra doc links
mxinden 3df6660
Thread local receive buffer
mxinden 52dfa91
Cleanup UdpSocket::recv_inner
mxinden 8699209
Revert "Thread local receive buffer"
mxinden 1b9259c
Fix fuzzing
mxinden 07c2b3b
Reduce diff
mxinden 14a9643
Runner::new
mxinden f0855e1
Cleanup server
mxinden 936ea2b
Cleanup datagram.rs
mxinden 19a82cd
Rename new_with_buffer to new
mxinden 55adc20
simplify codec.rs
mxinden 1cee426
Remove encode_into
mxinden e9dd74d
Document segment_size
mxinden 99a323e
Cleanup datagram.rs
mxinden 147df66
Address separate write buffer TODO
mxinden 3928c62
Fix fuzz
mxinden 34d904e
Fix fuzzing
mxinden 7f6ca94
Address TODO
mxinden bd325fe
Test previous client behaviour
mxinden 28f9b0a
Minor changes
mxinden 7cae54f
Remove outdated TODO
mxinden b03f8d4
build_vn test
mxinden 2003c84
Rename process to process_into_buffer
mxinden 38179ef
Rename process_alloc to process
mxinden fbccdf2
Merge branch 'main' of https://github.com/mozilla/neqo into send-recv…
mxinden 24e0cbd
Fix docs
mxinden 6deaef8
Rename write_buffer to out
mxinden 5244fc1
Re-introduce process_output
mxinden 15eb2f8
Address minor TODOs
mxinden ffc3708
Encode update frame directly
mxinden e5bc0e2
Document panic
mxinden eb09a9a
Remove outdated clippy allow
mxinden 5ab4e01
allow too_many_arguments in build_packet_header
mxinden 08c49e6
Fix build_insufficient_space
mxinden 2b0103a
Fix build_two
mxinden c254319
Merge branch 'main' of https://github.com/mozilla/neqo into send-recv…
mxinden 1bd20da
Make PacketBuilder limit an Option<usize>
mxinden 8137e73
No unsafe in recv_inner
mxinden 166ae86
Minor TODOs
mxinden 93c1fa5
Update NLL borrow-issue comment
mxinden 3a134d6
Simplify server.rs
mxinden 61565b4
Polonius workflow
mxinden f65dde5
Remove duplicate runs-on
mxinden c6f58dc
newline
mxinden 55e650f
Duplicate only
mxinden 92c48de
Fix diff
mxinden a4d1ef2
test(udp): fix recv_buf initialization
mxinden 75c1de2
Clippy
mxinden 1ce5455
Update diff
mxinden 91fbc6b
Use git
mxinden f675eb9
Reduce diff
mxinden d0916a8
clippy
mxinden bf807b8
Add Datagram segment unit tests
mxinden 760aade
Remove Http3Client::process_input
mxinden 589b8b4
Reduce diff
mxinden 30593e3
Improve docs
mxinden 5ad1f35
Copy segment size when saving datagram
mxinden 136a8c4
Line break comment
mxinden b070374
Use Datagram::num_segments
mxinden 55219b8
Revert "Remove Http3Client::process_input"
mxinden e247d47
Mark process_input for testing only
mxinden 6b30ee5
Fix GRO test
mxinden f57d1b2
Remove reference to process_input
mxinden f866a2a
Merge branch 'main' of https://github.com/mozilla/neqo into send-recv…
mxinden 24ba2d4
%s/_inx/_index
mxinden fe6ed10
Return error and do debug_assert on non-empty send buf
mxinden 6aa438d
%s/with/in
mxinden 364f5bd
Remove impl Copy for Datagram
mxinden f5b2d7f
Introduce BorrowedDatagram
mxinden bbb93cc
Encoder encode into &mut [u8] instead of &mut Vec<u8>
mxinden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
diff --git a/neqo-http3/src/server.rs b/neqo-http3/src/server.rs | ||
index 9b73f2c7..d6cd39a2 100644 | ||
--- a/neqo-http3/src/server.rs | ||
+++ b/neqo-http3/src/server.rs | ||
@@ -120,12 +120,7 @@ impl Http3Server { | ||
out: &'a mut Vec<u8>, | ||
) -> Output<&'a [u8]> { | ||
qtrace!([self], "Process."); | ||
- let mut output = self.server.process_into_buffer( | ||
- dgram, | ||
- now, | ||
- // See .github/workflows/polonius.yml. | ||
- unsafe { &mut *std::ptr::from_mut(out) }, | ||
- ); | ||
+ let mut output = self.server.process_into_buffer(dgram, now, out); | ||
|
||
self.process_http3(now); | ||
|
||
diff --git a/neqo-transport/src/server.rs b/neqo-transport/src/server.rs | ||
index 2446f8d3..25ceb2b0 100644 | ||
--- a/neqo-transport/src/server.rs | ||
+++ b/neqo-transport/src/server.rs | ||
@@ -445,12 +445,7 @@ impl Server { | ||
let mut callback = None; | ||
|
||
for connection in &mut self.connections { | ||
- match connection.borrow_mut().process_into_buffer( | ||
- None, | ||
- now, | ||
- // See .github/workflows/polonius.yml. | ||
- unsafe { &mut *std::ptr::from_mut(out) }, | ||
- ) { | ||
+ match connection.borrow_mut().process_into_buffer(None, now, out) { | ||
Output::None => {} | ||
d @ Output::Datagram(_) => return d, | ||
Output::Callback(next) => match callback { | ||
@@ -491,12 +486,7 @@ impl Server { | ||
|
||
#[allow(clippy::option_if_let_else)] | ||
let output = if let Some(dgram) = dgram { | ||
- self.process_input( | ||
- dgram, | ||
- now, | ||
- // See .github/workflows/polonius.yml. | ||
- unsafe { &mut *std::ptr::from_mut(out) }, | ||
- ) | ||
+ self.process_input(dgram, now, out) | ||
} else { | ||
Output::None | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Rustc by default uses the NLL borrow-checker. There are multiple cases where | ||
# NLL is too restrictive. An upcoming improvement to Rust's borrow-checker, | ||
# adressing these shortcomings, is Polonius. It ships with Nightly behind a | ||
# flag. | ||
# | ||
# This workflow first removes the workarounds necessary to please NLL and then | ||
# runs with Polonius to ensure each workaround only fixes the false-positive of | ||
# NLL and doesn't mask an actually undefined behavior. | ||
# | ||
# See also: | ||
# - <https://blog.rust-lang.org/inside-rust/2023/10/06/polonius-update.html> | ||
# - <https://github.com/rust-lang/rust/issues/54663> | ||
|
||
name: Polonius | ||
on: | ||
push: | ||
branches: ["main"] | ||
paths-ignore: ["*.md", "*.png", "*.svg", "LICENSE-*"] | ||
pull_request: | ||
branches: ["main"] | ||
paths-ignore: ["*.md", "*.png", "*.svg", "LICENSE-*"] | ||
merge_group: | ||
workflow_dispatch: | ||
env: | ||
CARGO_TERM_COLOR: always | ||
RUST_BACKTRACE: 1 | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref_name }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
polonius: | ||
strategy: | ||
fail-fast: false | ||
defaults: | ||
run: | ||
shell: bash | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
- uses: ./.github/actions/rust | ||
with: | ||
version: nightly | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- id: nss-version | ||
run: echo "minimum=$(cat neqo-crypto/min_version.txt)" >> "$GITHUB_OUTPUT" | ||
|
||
- uses: ./.github/actions/nss | ||
with: | ||
minimum-version: ${{ steps.nss-version.outputs.minimum }} | ||
|
||
- name: Apply patch, removing `unsafe` workarounds. | ||
run: git apply .github/workflows/polonius.diff | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't really the best place to keep this diff. Put it in the tree. |
||
|
||
- run: RUSTFLAGS="-Z polonius" cargo +nightly check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Somewhat unconventional. Still, I think statically proving
unsafe
code to be safe is worth it. As always, open for alternative suggestions.