Uploaded image for project: 'Guacamole'
  1. Guacamole
  2. GUACAMOLE-1776

Base64 encoding of image/binary data results in excessive syscalls that can degrade performance

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Done
    • None
    • 1.6.0
    • guacamole-server
    • None

    Description

      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.

      Attachments

        1. vtune_profile.png
          247 kB
          Christopher Speck

        Activity

          People

            Unassigned Unassigned
            cspeckrun Christopher Speck
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: