[ 
https://issues.apache.org/jira/browse/THRIFT-6290?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jens Geyer resolved THRIFT-6290.
--------------------------------
    Fix Version/s: 0.26.0
       Resolution: Fixed

Thanks [lbarthon (Louis)|https://github.com/lbarthon]

> 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
>            Priority: Minor
>             Fix For: 0.26.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> 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)

Reply via email to