You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@guacamole.apache.org by "Christopher Speck (Jira)" <ji...@apache.org> on 2023/04/19 18:37:00 UTC

[jira] [Created] (GUACAMOLE-1776) Base64 encoding of image/binary data results in excessive syscalls that can degrade performance

Christopher Speck created GUACAMOLE-1776:
--------------------------------------------

             Summary: Base64 encoding of image/binary data results in excessive syscalls that can degrade performance
                 Key: GUACAMOLE-1776
                 URL: https://issues.apache.org/jira/browse/GUACAMOLE-1776
             Project: Guacamole
          Issue Type: Improvement
          Components: guacamole-server
    Affects Versions: 1.3.0
            Reporter: Christopher Speck
         Attachments: vtune_profile.png

When sending image/binary data to a socket the data is base64 encoded and buffered in a way that incurs an excessive number of system calls which can degrade performance.

 

This occurs in {{socket.c}} where {{guac_socket_write_base64}} ends up calling {{guac_socket_write}} in a tight loop, once for every 3 bytes being encoded. The system calls this incurs are:
 * {{clock_gettime}} via {{guac_timestamp_current}}
 * {{{}pthread_mutex_rdlock{}}}/{{{}unlock{}}} via {{guac_socket_fd_write_handler}}

Attached an image of VTune profiling which shows that very little time is spent in guac_socket_fd_write_buffered but a lot of time is spent in the syscalls outlined.

 

Introducing a buffer(~1kb) to append data being encoded prior to writing to the socket results in a performance increase, reducing the time spent on the syscalls. For relative comparison in our test we started with 13fps and by introducing the buffer saw an increase to 23fps.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)