GUACAMOLE-2318: Reduce write() overhead when encoding protocol instru… - #704
Open
Heyzi wants to merge 1 commit into
Open
GUACAMOLE-2318: Reduce write() overhead when encoding protocol instru…#704Heyzi wants to merge 1 commit into
Heyzi wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 - forcopythat'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
NULLstring 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).