kpumuk opened a new pull request, #3713: URL: https://github.com/apache/thrift/pull/3713
<!-- Explain the changes in the pull request below: --> Ruby clients and servers skip fields they do not recognize when communicating across schema versions. The shared Ruby protocol path currently handles skipped `STRING` values through `read_string`. Binary and Compact protocols therefore construct a UTF-8 string from the raw bytes even though the value is immediately discarded. This change gives protocols control over how skipped strings are consumed. Binary and Compact use their binary readers, while the base protocol preserves the existing string behavior for custom protocols. JSON continues reading skipped values as strings because JSON strings and binary values have different wire representations. Header and decorated protocols forward the operation to their selected or wrapped protocol. The wire bytes consumed are unchanged. The change only avoids unnecessary representation work when Binary or Compact string values are skipped. ## Benchmarks The benchmark used Ruby 4.0.6 on aarch64 Linux and skipped 100,000 strings of 128 bytes each. Each result is the median of five measured trials after one warm-up trial. The same temporary harness and configuration were run against master commit `9b10484ca7687af6cc67567df9d457d0f031748e` and the proposed change: ```bash bundle exec ruby /tmp/rb_skip_string_benchmark.rb THRIFT_BENCHMARK_SKIP_NATIVE=1 bundle exec ruby /tmp/rb_skip_string_benchmark.rb ``` | Mode and protocol | Master median | Proposed median | Runtime delta | Allocated objects | | --- | ---: | ---: | ---: | ---: | | Native Binary | 70.250 ms | 56.999 ms | -18.86% | 303,181 → 203,181 (-32.98%) | | Native Compact | 59.493 ms | 52.577 ms | -11.63% | 203,132 → 103,132 (-49.23%) | | Native Binary accelerated | 55.630 ms | 44.984 ms | -19.14% | 203,180 → 103,180 (-49.22%) | | Pure Ruby Binary | 130.605 ms | 120.119 ms | -8.03% | 306,355 → 206,355 (-32.64%) | | Pure Ruby Compact | 122.418 ms | 108.034 ms | -11.75% | 306,258 → 206,258 (-32.65%) | JSON must retain its string-reading path. A separate alternating paired benchmark of 20,000 skipped JSON strings measured the forwarding overhead at +0.53% in native mode and +0.06% in pure Ruby, with unchanged allocations. These are synthetic skip-only workloads on one Ruby version and architecture. The temporary harness is not included in the change. <!-- 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-6149](https://issues.apache.org/jira/browse/THRIFT-6149) - [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]
