ishaaaan17 opened a new pull request, #13901:
URL: https://github.com/apache/trafficserver/pull/13901

   ## summary
   in `xpack_encode_string`, use huffman encoding only when the encoded output 
is strictly smaller than the unencoded string length.
   
   before this, `use_huffman = true` was hardcoded with a `TODO: Choose whether 
to use Huffman encoding wisely`. for strings with high-byte characters or 
binary data, where huffman codewords are 20-30 bits per byte, huffman encoding 
makes the wire size bigger and wastes the peer's cpu on decompression. rfc 7541 
(section 5.2) and rfc 9204 say that encoders should use huffman coding only 
when the result is smaller than the raw string.
   
   ## changes
   - in `xpack_encode_string`, check if huffman coding makes the representation 
smaller (`value_len == 0 || data_len < value_len`).
   - if huffman encoding would make it bigger, the string is encoded as a raw 
string literal (`*p &= ~(0x01 << n)`).
   - added a unit test in `test_XPACK.cc` to check that strings that don't 
compress are encoded without huffman and decode correctly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to