Skip to content

Commit de67e58

Browse files
elmarcoCBenoit
authored andcommitted
perf(server): make tiles encoding parallel with rayon
This can help a lot wall-clock time, but depends on CPU. rfx_enc time: [9.7885 ms 10.123 ms 10.439 ms] change: [-80.484% -79.847% -79.208%] (p = 0.00 < 0.05) Performance has improved. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
1 parent 58afe28 commit de67e58

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ironrdp-server/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ doctest = true
1616
test = false
1717

1818
[features]
19+
default = ["rayon"]
1920
helper = ["dep:x509-cert", "dep:rustls-pemfile"]
21+
rayon = ["dep:rayon"]
2022

2123
# Internal (PRIVATE!) features used to aid testing.
2224
# Don't rely on these whatsoever. They may disappear at any time.
@@ -42,6 +44,7 @@ ironrdp-rdpsnd.workspace = true
4244
tracing.workspace = true
4345
x509-cert = { version = "0.2.5", optional = true }
4446
rustls-pemfile = { version = "2.2.0", optional = true }
47+
rayon = { version = "1.10.0", optional = true }
4548

4649
[dev-dependencies]
4750
tokio = { version = "1", features = ["sync"] }

crates/ironrdp-server/src/encoder/rfx.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,16 @@ impl<'a> UpdateEncoder<'a> {
144144
}
145145

146146
fn encode(&self, data: &'a mut UpdateEncoderData) -> EncodeResult<Vec<rfx::Tile<'a>>> {
147+
#[cfg(feature = "rayon")]
148+
use rayon::prelude::*;
149+
147150
let (tiles_x, tiles_y) = self.tiles_xy();
148151

152+
#[cfg(not(feature = "rayon"))]
149153
let chunks = data.0.chunks_mut(64 * 64 * 3);
154+
#[cfg(feature = "rayon")]
155+
let chunks = data.0.par_chunks_mut(64 * 64 * 3);
156+
150157
let tiles: Vec<_> = (0..tiles_y).flat_map(|y| (0..tiles_x).map(move |x| (x, y))).collect();
151158

152159
chunks

0 commit comments

Comments
 (0)