kpumuk opened a new pull request, #3748:
URL: https://github.com/apache/thrift/pull/3748

   <!-- Explain the changes in the pull request below: -->
   
   Malformed request arguments can raise a `ProtocolException` while a 
generated Ruby processor is decoding its argument structure. The processor 
currently handles that exception together with handler failures and returns 
`INTERNAL_ERROR`, making malformed protocol data appear to clients as a 
server-side failure.
   
   This change marks protocol exceptions at the argument-reading boundary and 
returns an application exception with the `PROTOCOL_ERROR` type, preserving the 
original message, method name, and sequence ID. Protocol exceptions raised 
later by application handlers remain classified as `INTERNAL_ERROR`.
   
   ## Benchmarks
   
   The successful `read_args` path was measured on Ruby 4.0.6/aarch64-linux 
with one CPU pinned, a 500,000-call warmup, and 15 trials of 5,000,000 calls:
   
   ```sh
   taskset -c 0 bundle exec ruby -e 'require "thrift"; class BenchProcessor; 
include Thrift::Processor; end; class BenchArgs; def read(_protocol); end; end; 
class BenchProtocol; def read_message_end; end; end; processor = 
BenchProcessor.new(Object.new, Logger.new(IO::NULL)); protocol = 
BenchProtocol.new; 500_000.times { processor.read_args(protocol, BenchArgs) }; 
samples = 15.times.map do; started = 
Process.clock_gettime(Process::CLOCK_MONOTONIC); 5_000_000.times { 
processor.read_args(protocol, BenchArgs) }; 
Process.clock_gettime(Process::CLOCK_MONOTONIC) - started; end; sorted = 
samples.sort; p samples; p sorted.fetch(7)'
   ```
   
   Current master median: 0.786545 seconds  
   Proposed change median: 0.780384 seconds  
   Difference: -0.8%
   
   This synthetic benchmark uses no-op argument and protocol objects to 
emphasize processor dispatch overhead; it excludes protocol decoding, 
transport, and network work. The difference is within run-to-run noise and 
shows no measurable regression.
   
   <!-- We recommend you review the checklist/tips before submitting a pull 
request. -->
   
   - [x] Did you create an [Apache 
Jira](https://issues.apache.org/jira/projects/THRIFT/issues/) ticket? 
[THRIFT-6158](https://issues.apache.org/jira/browse/THRIFT-6158)
   - [x] If a ticket exists: Does your pull request title follow the pattern 
"THRIFT-NNNN: describe my issue"?
   - [x] Did you squash your changes to a single commit?  (not required, but 
preferred)
   - [x] Did you do your best to avoid breaking changes?  If one was needed, 
did you label the Jira ticket with "Breaking-Change"?
   - [ ] If your change does not involve any code, include `[skip ci]` anywhere 
in the commit message to free up build resources.
   
   <!--
     The Contributing Guide at:
     https://github.com/apache/thrift/blob/master/CONTRIBUTING.md
     has more details and tips for committing properly.
   -->
   


-- 
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