Skip to content

GUACAMOLE-2318: Reduce write() overhead when encoding protocol instru… - #704

Open
Heyzi wants to merge 1 commit into
apache:staging/1.6.1from
Heyzi:GUACAMOLE-2318
Open

GUACAMOLE-2318: Reduce write() overhead when encoding protocol instru…#704
Heyzi wants to merge 1 commit into
apache:staging/1.6.1from
Heyzi:GUACAMOLE-2318

Conversation

@Heyzi

@Heyzi Heyzi commented Aug 9, 2026

Copy link
Copy Markdown

GUACAMOLE-2318: Reduce write() overhead when encoding protocol instructions

Every field of a guac_protocol_send_*() instruction was written to the socket as its own separate call - for copy that's 30+ small locked writes per instruction. Now each "<length>.<value>" element is built into one buffer and written in a single call. Wire format is unchanged.

Also fixed: a NULL string passed to __guac_socket_write_length_string() used to crash guacd; now treated as empty, like the rest of libguac.

Benchmarks (real build, Linux/glibc, not synthetic):

  • copy: ~1730 → ~1220 ns/call (-30%)
  • transform: ~2020 → ~1610 ns/call (-20%)
  • name: ~227 → ~205 ns/call (-10%)

CPU-only, no memory impact.

Testing: 79/79 existing unit tests pass; added a test covering boundary values (INT64_MIN/MAX, empty/NULL string, extreme doubles).

…ctions.

Each length-prefixed element ("<length>.<value>") in a guac_protocol_send_*()
instruction previously went to the socket as multiple separate writes, each
independently taking the buffer lock. Build each element into a single
buffer and write it in one call instead; wire format is unchanged.

Also treat a NULL string in __guac_socket_write_length_string() as empty
rather than crashing, matching how the rest of libguac already handles NULL.
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.

1 participant