Closed abrandoned closed 5 years ago
Overall, this looks good. I especially appreciate getting rid of that crazy set_field
method with all of the nested conditionals. 💯
Any idea what's up with all the failing specs?
I've read through this PR several times now and it looks good to me. If specs are passing I think we're good to cut a pre-release. Nice work, @abrandoned !
Quite a few optimizations for MRI and JRuby; started with too large a cut (including some protobuf java helpers for varint encoding) but paired back to just including optimizations in the first PR. Will be starting another gem to include the varint changes for java (which yields another significant increase in perf for encode/decode)
@film42 @quixoten @brianstien @liveh2o
Primary optimizations were removing the need to do runtime checking of
map?
/repeated?
on field objects by writing the access methodsset/set_field/value_from_values
directly onto the field object; also sped up the access of eachget_field
call by using a constant dynamically defined on inherited object, JRuby has much faster access to Constants than class method lookups; also removed superfluous lookups of fields andrespond_to
calls to be replaced by methods on the field objectincluded the benchmark I ran as
varint_prof.rb
but will probably move it into a rake task so we can use it for future optimization; will also squash all the commits for a final merge but keeping them in the branch for now as changes are discussedBenchmark/ips if encode/decode/to_hash on a protobuf message with MRI and JRuby below
JRuby -- approx 5x faster
to_hash
2.5x fasterencode
1.5x fasterdecode
MRI -- approx 3x faster
to_hash
1.3x fasterencode
1.2x fasterdecode