Skip to content
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

Optimize VNC screen update to reduce delays #84

Merged
merged 1 commit into from
Dec 25, 2024

Conversation

ndsl7109256
Copy link
Collaborator

Previously, the VNC renderer fed the damaged region to the buffer line by line, resulting in significant rendering delays due to frequent buffer updates.

The implementation has been optimized to aggregate all updates during the current screen refresh cycle. The buffer is now updated once per refresh with the complete damaged region, reducing rendering delays and preventing screen tearing.

Previously

Screen.Recording.2024-12-24.160010.mp4

After optimizing

Screen.Recording.2024-12-24.160117.mp4

Comparing

The table compares the performance of screen updating measuring with GIFs with significant vertical variations(Selected to better illustrate the delay caused by line-by-line buffer updates) , before and after optimization, measured in average execution time (ms). Numbers in parentheses represent the standard deviation (std).

GIF size Before After
128x128 4.049ms(3.363ms) 1.928ms(1.424 ms)
256x256 15.797ms(11.030ms) 2.196ms(1.064 ms)
512x512 52.259ms(30.524 ms) 2.379ms(1.138 ms)

Close #81

Previously, the VNC renderer fed the damaged region to the buffer line
by line, resulting in significant rendering delays due to frequent
buffer updates.

The implementation has been optimized to aggregate all updates during
the current screen refresh cycle. The buffer is now updated once per
refresh with the complete damaged region, reducing rendering delays and
preventing screen tearing.

Close sysprog21#81
@jserv jserv merged commit 501453e into sysprog21:main Dec 25, 2024
3 checks passed
@jserv
Copy link
Contributor

jserv commented Dec 25, 2024

Thank @ndsl7109256 for contributing!

@huaxinliao
Copy link
Collaborator

I am curious whether the experimental data in Comparing was generated with the assistance of other tools.

@ndsl7109256
Copy link
Collaborator Author

ndsl7109256 commented Dec 26, 2024

I first used gprof to check the hotspot of the VNC backend and found that _twin_vnc_work takes a significant amount of time.
Then, I measure how long _twin_vnc_work takes directly using 10-second samples.

+ clock_t start = clock();
twin_screen_t *screen = SCREEN(closure);
if (twin_screen_damaged(screen))
    twin_screen_update(screen);
+ clock_t end = clock();

@jserv
Copy link
Contributor

jserv commented Dec 26, 2024

I first used gprof to check the hotspot of the VNC backend and found that _twin_vnc_work takes a significant amount of time. Then, I measure how long _twin_vnc_work takes directly using 10-second samples.

uftrace is useful, tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rendering delay in VNC backend
3 participants