kpumuk opened a new pull request, #3708:
URL: https://github.com/apache/thrift/pull/3708
<!-- Explain the changes in the pull request below: -->
Ruby transports may report end of input by returning `nil` or an empty
string. `BaseTransport#read_all` currently leaks a Ruby `NoMethodError` for
`nil`, while an empty result causes it to retry forever without making progress.
This change treats either result as `TransportException::END_OF_FILE` when
bytes are still required. Partial reads continue normally while each call makes
progress, and zero-size reads still return an empty binary string without
invoking the underlying transport.
The common path returns a complete first chunk directly. A short frozen
chunk is copied only when it must become the accumulator for subsequent reads.
## Benchmarks
The common exact-read path was measured in the dedicated Ruby container
using Ruby 4.0.6 on aarch64 Linux. A temporary stdlib benchmark used a
`BaseTransport` whose `read` method returned a frozen eight-byte binary string,
with 1,000,000 warmup calls followed by seven trials of 5,000,000 calls:
`bundle exec ruby -Ilib /tmp/rb-read-all-benchmark.rb`
- Master `c2def39207a73394420088da9b4b105571dd9036`: median 6,406,402
operations/second
- Proposed change: median 5,902,949 operations/second
- Difference: −7.9%
This deliberately removes all underlying I/O and therefore magnifies the
cost of the EOF and progress checks. Network, file, and layered transports
should spend most of their time in the underlying read. Returning a complete
first chunk directly avoids the allocation and copy that an intermediate
accumulator would otherwise add.
<!-- 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-6144](https://issues.apache.org/jira/browse/THRIFT-6144)
- [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]