-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
chore(codecs): Implement additional Encoder
/EncodingConfig
without framing
#12156
Conversation
✅ Deploy Preview for vector-project canceled.
|
Encoder
/EncodingConfig
without framingEncoder
/EncodingConfig
without framing
ea7e3c7
to
b0ff768
Compare
Soak Test ResultsBaseline: e2530d8 ExplanationA soak test is an integrated performance test for vector in a repeatable rig, with varying configuration for vector. What follows is a statistical summary of a brief vector run for each configuration across SHAs given above. The goal of these tests are to determine, quickly, if vector performance is changed and to what degree by a pull request. Where appropriate units are scaled per-core. The table below, if present, lists those experiments that have experienced a statistically significant change in their throughput performance between baseline and comparision SHAs, with 90.0% confidence OR have been detected as newly erratic. Negative values mean that baseline is faster, positive comparison. Results that do not exhibit more than a ±7.0% change in mean throughput are discarded. An experiment is erratic if its coefficient of variation is greater than 0.3. The abbreviated table will be omitted if no interesting changes are observed. No interesting changes in throughput with confidence ≥ 90.00% and absolute Δ mean >= ±7.0%: Fine details of change detection per experiment.
Fine details of each soak run.
|
Signed-off-by: Pablo Sichert <mail@pablosichert.com>
b0ff768
to
c0862c5
Compare
Soak Test ResultsBaseline: e2530d8 ExplanationA soak test is an integrated performance test for vector in a repeatable rig, with varying configuration for vector. What follows is a statistical summary of a brief vector run for each configuration across SHAs given above. The goal of these tests are to determine, quickly, if vector performance is changed and to what degree by a pull request. Where appropriate units are scaled per-core. The table below, if present, lists those experiments that have experienced a statistically significant change in their throughput performance between baseline and comparision SHAs, with 90.0% confidence OR have been detected as newly erratic. Negative values mean that baseline is faster, positive comparison. Results that do not exhibit more than a ±7.0% change in mean throughput are discarded. An experiment is erratic if its coefficient of variation is greater than 0.3. The abbreviated table will be omitted if no interesting changes are observed. No interesting changes in throughput with confidence ≥ 90.00% and absolute Δ mean >= ±7.0%: Fine details of change detection per experiment.
Fine details of each soak run.
|
pub struct Encoder { | ||
pub struct Encoder<Framer> | ||
where | ||
Framer: Clone, |
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.
Why generics instead of just making framer an Option
?
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.
Because this allows us to specialize the implementations for impl tokio_util::codec::Encoder<Event> for Encoder<Framer>
and impl tokio_util::codec::Encoder<Event> for Encoder<()>
at compile time such that they are branch free:
impl tokio_util::codec::Encoder<Event> for Encoder<Framer> {
type Error = Error;
fn encode(&mut self, event: Event, buffer: &mut BytesMut) -> Result<(), Self::Error> {
let len = buffer.len();
let mut payload = buffer.split_off(len);
self.serialize(event, &mut payload)?;
// Frame the serialized event.
self.framer.encode((), &mut payload).map_err(|error| {
emit!(EncoderFramingFailed { error: &error });
Error::FramingError(error)
})?;
buffer.unsplit(payload);
Ok(())
}
}
impl tokio_util::codec::Encoder<Event> for Encoder<()> {
type Error = Error;
fn encode(&mut self, event: Event, buffer: &mut BytesMut) -> Result<(), Self::Error> {
let len = buffer.len();
let mut payload = buffer.split_off(len);
self.serialize(event, &mut payload)?;
buffer.unsplit(payload);
Ok(())
}
}
Meaning that when we know that no framer is used we don't need to check for its known absence, same (but inverse) when using an encoder with a known framer. Since this is a very hot path, the difference can be within the order of 5-10% throughput, as can also be seen in the benchmarks in #10684 (comment).
This PR adds support structures needed to have both an
Encoder<()>
(no framing) andEncoder<Framer>
(with framing), both of which emit internal logs when encoding fails.Some context that triggered the need for this: #12133 (comment).