Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

perf(app): send gateway frames with a 128 KiB zstd window

Hampusebb8a7bb8b23
diff --git a/fluxer_app/rust/libfluxcore/src/zstd_stream.rs b/fluxer_app/rust/libfluxcore/src/zstd_stream.rs
index 4e3c8e57b..6904474cd 100644
--- a/fluxer_app/rust/libfluxcore/src/zstd_stream.rs
+++ b/fluxer_app/rust/libfluxcore/src/zstd_stream.rs
@@ -5,6 +5,8 @@ use zstd::zstd_safe::{CCtx, CParameter, DCtx, InBuffer, OutBuffer};
const READ_BUFFER_BYTES: usize = 16 * 1024;
const MAX_DECOMPRESSED_BYTES: usize = 64 * 1024 * 1024;
+const ENCODER_WINDOW_LOG: u32 = 17;
+const ENCODER_TABLE_LOG: u32 = 15;
#[derive(Debug)]
pub enum ZstdError {
@@ -32,9 +34,16 @@ pub struct ZstdStreamEncoder {
impl ZstdStreamEncoder {
pub fn new(level: i32) -> Result<Self, ZstdError> {
let mut context = CCtx::try_create().ok_or(ZstdError::OutOfMemory)?;
- context
- .set_parameter(CParameter::CompressionLevel(level))
- .map_err(|_| ZstdError::Encode)?;
+ for parameter in [
+ CParameter::CompressionLevel(level),
+ CParameter::WindowLog(ENCODER_WINDOW_LOG),
+ CParameter::HashLog(ENCODER_TABLE_LOG),
+ CParameter::ChainLog(ENCODER_TABLE_LOG),
+ ] {
+ context
+ .set_parameter(parameter)
+ .map_err(|_| ZstdError::Encode)?;
+ }
Ok(Self { context })
}