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

   <!-- Explain the changes in the pull request below: -->
   
   Ruby is on a gradual path toward frozen string literals by default. That 
transition began in Ruby 3.4.0 with chilled strings, but we can get the 
benefits today by explicitly enabling {{# frozen_string_literal: true}}. Doing 
so reduces avoidable string allocations and copies, lets the VM do less work, 
removes many manual {{.freeze}} workarounds, and can deliver meaningful 
performance improvements in allocation-heavy code paths.
   
   This change adds frozen string literal to all generated files, and also 
library files. There is one performance issue in JSON protocol I noticed where 
we used `+=` on strings instead of `<<`, which allocates much more objects than 
necessary, and you can clearly see the gain in the profile table below.
   
   ### Benchmark
   
   Settings:
   - `THRIFT_BENCHMARK_SKIP_NATIVE=1`
   - `large_runs=2`
   - `small_runs=50000`
   
   Allocations are per-scenario `GC.stat(:total_allocated_objects)` deltas 
after warm-up. `Page Δ` is `total_allocated_pages` after-before.
   
   | Scenario | Before s | After s | Time Δ | Objects before | Objects after | 
Obj Δ | Page Δ |
   | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
   | `rb-bin-write-large` | 0.6693 | 0.6405 | -4.30% | 3425466 | 2268526 | 
-33.77% | 0 |
   | `rb-bin-read-large` | 0.8936 | 0.9210 | +3.07% | 2419330 | 1796699 | 
-25.74% | -12 |
   | `rb-cmp-write-large` | 0.7115 | 0.6830 | -4.01% | 3185756 | 2082652 | 
-34.63% | -8 |
   | `rb-cmp-read-large` | 0.7644 | 0.7667 | +0.30% | 1305533 | 1220816 | 
-6.49% | -20 |
   | `rb-json-write-large` | 2.6985 | 2.3396 | -13.30% | 19912447 | 12894100 | 
-35.25% | -258 |
   | `rb-json-read-large` | 4.1582 | 3.9063 | -6.06% | 21517002 | 12230690 | 
-43.16% | -229 |
   | `rb-bin-write-small` | 0.7956 | 0.7579 | -4.74% | 4200013 | 2800011 | 
-33.33% | -9 |
   | `rb-bin-read-small` | 0.9819 | 0.9384 | -4.43% | 2851890 | 2101889 | 
-26.30% | -1 |
   | `rb-cmp-write-small` | 0.8381 | 0.8000 | -4.54% | 3850014 | 2550012 | 
-33.77% | 0 |
   | `rb-cmp-read-small` | 0.8127 | 0.8207 | +1.00% | 1501207 | 1401206 | 
-6.66% | +1 |
   | `rb-json-write-small` | 3.1718 | 2.7987 | -11.76% | 23650013 | 15400012 | 
-34.88% | -12 |
   | `rb-json-read-small` | 4.7816 | 4.4036 | -7.90% | 25254576 | 14554576 | 
-42.37% | 0 |
   | `hdr-bin-write-small` | 1.0757 | 1.0487 | -2.51% | 5550025 | 3600021 | 
-35.14% | 0 |
   | `hdr-bin-read-small` | 1.4021 | 1.4863 | +6.01% | 5702295 | 4652292 | 
-18.41% | +1 |
   | `hdr-cmp-write-small` | 1.1261 | 1.0931 | -2.93% | 5200026 | 3350022 | 
-35.58% | 0 |
   | `hdr-cmp-read-small` | 1.2724 | 1.3736 | +7.96% | 4251636 | 3851633 | 
-9.41% | +1 |
   | `hdr-zlib-write-small` | 1.3556 | 1.3100 | -3.36% | 5850025 | 3850021 | 
-34.19% | 0 |
   | `hdr-zlib-read-small` | 1.4859 | 1.5700 | +5.66% | 5902461 | 4852458 | 
-17.79% | -1 |
   
   <!-- 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-5950](https://issues.apache.org/jira/browse/THRIFT-5950)
   - [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