Alexandr created GUACAMOLE-2318:
-----------------------------------

             Summary: Reduce write() overhead when encoding Guacamole protocol 
instructions in libguac
                 Key: GUACAMOLE-2318
                 URL: https://issues.apache.org/jira/browse/GUACAMOLE-2318
             Project: Guacamole
          Issue Type: Improvement
          Components: guacd
            Reporter: Alexandr


Right now every field of a guac_protocol_send_* instruction (copy, transform, 
cursor, etc.) goes to the socket as its own separate write - for something like 
copy that's 30+ small locked writes per instruction, each taking the buffer 
mutex and doing its own memcpy, plus a redundant snprintf per field.

Batched each "<length>.<value>" element into a single stack buffer and write it 
in one call instead. Wire format is unchanged - this only cuts the number of 
write() calls.

Benchmarked against a real build Linux/glibc:
{code:java}
copy: ~1730 → ~1220 ns/call (-30%)
transform: ~2020 → ~1610 ns/call (-20%)
name: ~227 → ~205 ns/call (-10%){code}
Pure CPU win, no change in memory usage - same stack buffers, no new 
allocations.



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

Reply via email to