Skip to content

Preliminary refactoring patches for QOI#730

Merged
Benoît Cortier (CBenoit) merged 10 commits into
Devolutions:masterfrom
elmarco:server
Mar 31, 2025
Merged

Preliminary refactoring patches for QOI#730
Benoît Cortier (CBenoit) merged 10 commits into
Devolutions:masterfrom
elmarco:server

Conversation

@elmarco
Copy link
Copy Markdown
Contributor

@elmarco Marc-Andre Lureau (elmarco) commented Mar 29, 2025

subset of commits taken from #670

@CBenoit
Copy link
Copy Markdown
Member

Benoît Cortier (CBenoit) commented Mar 30, 2025

For API breaking refactors, can you use fix! or feat!? refactor commits are not considered for triggering a version bump (but I may adjust things if necessary)

Comment thread crates/ironrdp-server/src/display.rs
pub width: NonZeroU16,
pub height: NonZeroU16,
pub format: PixelFormat,
pub data: BytesMut,
Copy link
Copy Markdown
Member

@CBenoit Benoît Cortier (CBenoit) Mar 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: What is the benefit of using BytesMut over Vec<u8> at this place?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not nessarily a Vec, we may have shared memory. Although I realize shared memory may be problematic too... Perhaps a whole copy is inavoidable..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User has to be careful that shared memory will be owned by the server. But we should still allow shared memory to avoid copy.

Copy link
Copy Markdown
Member

@CBenoit Benoît Cortier (CBenoit) Mar 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that at some point freeze() or alike is called, and memory is actually shared then?
This sounds good to me, but as you point out, let’s be careful about how we use this: we experienced issues in the past where the way BytesMut was used caused too much memory being allocated and freed, resulting in both performance and memory usage being poor. (Big chunk of memory may also never get freed, as long as a view on it is remaining, even if it’s a very small view. And how BytesMut is used is also very relevant.)
I assume you are measuring the CPU and memory usage, and have a good insight. It would help avoid regressions to add some in-line comments to document the decision.

Comment thread crates/ironrdp-bench/benches/bench.rs
Comment thread crates/ironrdp-server/src/encoder/mod.rs
Dealing with multiple formats is sufficiently annoying, there isn't much
need for awkward image layout. This was done for efficiency reason for
bitmap encoding, but bitmap is really inefficient anyway and very few
servers will actually provide bottom to top images (except with GL/GPU
textures, but this is not in scope yet).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This will hold the updated bitmap data for the whole framebuffer.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This is more idiomatic, and thus less confusing.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
The bitmap encoder dispatching code was becoming convoluted and the same
struct was handling PduEncoding and various bitmap encoding handling.
Instead, split UpdateEncoder in different types and concerns.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
It should reflect client drawing state.

In following changes, we will fix it to draw bitmap updates on it, to
keep it up to date.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Copy link
Copy Markdown
Member

@CBenoit Benoît Cortier (CBenoit) left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@CBenoit Benoît Cortier (CBenoit) merged commit aeb1193 into Devolutions:master Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants