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

perf(bin/server): increase msg size and don't allocate msg per resp #1772

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions neqo-bin/src/bin/server/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// except according to those terms.

use std::{
borrow::Cow,
cell::RefCell,
cmp::min,
collections::HashMap,
Expand Down Expand Up @@ -196,7 +197,7 @@ trait HttpServer: Display {
}

struct ResponseData {
data: Vec<u8>,
data: Cow<'static, [u8]>,
offset: usize,
remaining: usize,
}
Expand All @@ -211,17 +212,17 @@ impl From<Vec<u8>> for ResponseData {
fn from(data: Vec<u8>) -> Self {
let remaining = data.len();
Self {
data,
data: Cow::Owned(data.into()),
offset: 0,
remaining,
}
}
}

impl ResponseData {
fn repeat(buf: &[u8], total: usize) -> Self {
fn repeat(buf: &'static [u8], total: usize) -> Self {
Self {
data: buf.to_owned(),
data: Cow::Borrowed(buf),
offset: 0,
remaining: total,
}
Expand Down Expand Up @@ -260,14 +261,7 @@ struct SimpleServer {
}

impl SimpleServer {
const MESSAGE: &'static [u8] = b"I am the very model of a modern Major-General,\n\
I've information vegetable, animal, and mineral,\n\
I know the kings of England, and I quote the fights historical\n\
From Marathon to Waterloo, in order categorical;\n\
I'm very well acquainted, too, with matters mathematical,\n\
I understand equations, both the simple and quadratical,\n\
About binomial theorem, I'm teeming with a lot o' news,\n\
With many cheerful facts about the square of the hypotenuse.\n";
const MESSAGE: &'static [u8] = &[0; 4096];
larseggert marked this conversation as resolved.
Show resolved Hide resolved

pub fn new(
args: &Args,
Expand Down
Loading