Skip to content

Commit bd77542

Browse files
WonshtrumKeksoj
authored andcommitted
Performance and stability improvements
- remove kawa delimiters (it overly fragments the writes and slows h2 tremendously) - check rustls buffers before the socket (to reduce syscalls) - ignore empty data frames with end stream on close stream (all the stream management should be revised honestly) - only count the active streams when checking if opening a new one would overflow the max concurrent allowed (again... stream management = bad) - log the precise reason of any goaway - properly reset metrics - display total time and backend response time in access logs (will soon changed when rebase on main) Signed-off-by: Eloi DEMOLIS <[email protected]>
1 parent 25abac0 commit bd77542

File tree

7 files changed

+167
-106
lines changed

7 files changed

+167
-106
lines changed

lib/src/protocol/mux/converter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl<'a, T: AsBuffer> BlockConverter<T> for H2BlockConverter<'a> {
150150
.unwrap();
151151
kawa.push_out(Store::from_slice(&header));
152152
kawa.push_out(data);
153-
kawa.push_delimiter();
153+
// kawa.push_delimiter();
154154
return can_continue;
155155
}
156156
Block::Flags(Flags {
@@ -189,7 +189,7 @@ impl<'a, T: AsBuffer> BlockConverter<T> for H2BlockConverter<'a> {
189189
kawa.push_out(Store::from_slice(&header));
190190
}
191191
if end_header || end_stream {
192-
kawa.push_delimiter()
192+
// kawa.push_delimiter()
193193
}
194194
}
195195
}

lib/src/protocol/mux/h1.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::time::Instant;
2+
13
use sozu_command::ready::Ready;
24

35
use crate::{
@@ -42,6 +44,9 @@ impl<Front: SocketHandler> ConnectionH1<Front> {
4244
println_!("======= MUX H1 READABLE {:?}", self.position);
4345
self.timeout_container.reset();
4446
let stream = &mut context.streams[self.stream];
47+
if stream.metrics.start.is_none() {
48+
stream.metrics.start = Some(Instant::now());
49+
}
4550
let parts = stream.split(&self.position);
4651
let kawa = parts.rbuffer;
4752
let (size, status) = self.socket.socket_read(kawa.storage.space());
@@ -144,19 +149,19 @@ impl<Front: SocketHandler> ConnectionH1<Front> {
144149
let kawa = &mut stream.back;
145150
match kawa.detached.status_line {
146151
kawa::StatusLine::Response { code: 101, .. } => {
147-
println!("============== HANDLE UPGRADE!");
152+
debug!("============== HANDLE UPGRADE!");
148153
return MuxResult::Upgrade;
149154
}
150155
kawa::StatusLine::Response { code: 100, .. } => {
151-
println!("============== HANDLE CONTINUE!");
156+
debug!("============== HANDLE CONTINUE!");
152157
// after a 100 continue, we expect the client to continue with its request
153158
self.timeout_container.reset();
154159
self.readiness.interest.insert(Ready::READABLE);
155160
kawa.clear();
156161
return MuxResult::Continue;
157162
}
158163
kawa::StatusLine::Response { code: 103, .. } => {
159-
println!("============== HANDLE EARLY HINT!");
164+
debug!("============== HANDLE EARLY HINT!");
160165
if let StreamState::Linked(token) = stream.state {
161166
// after a 103 early hints, we expect the backend to send its response
162167
endpoint
@@ -181,9 +186,7 @@ impl<Front: SocketHandler> ConnectionH1<Front> {
181186
let old_state = std::mem::replace(&mut stream.state, StreamState::Unlinked);
182187
if stream.context.keep_alive_frontend {
183188
self.timeout_container.reset();
184-
// println!("{old_state:?} {:?}", self.readiness);
185189
if let StreamState::Linked(token) = old_state {
186-
// println!("{:?}", endpoint.readiness(token));
187190
endpoint.end_stream(token, self.stream, context);
188191
}
189192
self.readiness.interest.insert(Ready::READABLE);
@@ -285,7 +288,7 @@ impl<Front: SocketHandler> ConnectionH1<Front> {
285288
}
286289
(false, false) => {
287290
// we do not have an answer, but the request is untouched so we can retry
288-
println!("H1 RECONNECT");
291+
debug!("H1 RECONNECT");
289292
stream.state = StreamState::Link;
290293
}
291294
(false, true) => unreachable!(),

0 commit comments

Comments
 (0)