Santiago Medina created THRIFT-6290:
---------------------------------------
Summary: Rust: skip string/binary fields without heap-allocating
Key: THRIFT-6290
URL: https://issues.apache.org/jira/browse/THRIFT-6290
Project: Thrift
Issue Type: Improvement
Components: Rust - Library
Reporter: Santiago Medina
h3. Problem
After [THRIFT-5928], {{TInputProtocol::skip()}} consumes unknown string/binary
fields via {{read_bytes()}}. That is correct (no UTF-8 check), but it
heap-allocates a {{Vec<u8>}} the size of the field and immediately drops it.
Skipping a large unknown binary field therefore allocates on the hot path for
no reason.
h3. Proposed change
Binary and Compact protocols should read the length prefix, still enforce
negative sizes and {{max_string_size}}, then discard the payload through a
small stack buffer instead of materializing it.
A {{skip_binary()}} method on {{TInputProtocol}} lets those protocols
specialize; the default implementation keeps the allocating {{read_bytes()}}
path so custom protocol impls stay source-compatible.
h3. Related
* Follow-up to [THRIFT-5928]
* PR: [https://github.com/apache/thrift/pull/3854]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)