Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dig improvements #6632

merged 3 commits into from Mar 26, 2021

Dig improvements #6632

merged 3 commits into from Mar 26, 2021


Copy link

@headius headius commented Mar 26, 2021

These are small improvements for the dig method:

  • Arity-split up to three. These will be very common arities. We could split further in the future but with greatly diminishing returns.
  • Make known types (Array, Hash, Struct) use an iterative algorithm to dig out successive values. This avoids recursion for known types.

This work was originally intended to fix #6628 but the performance issue there was primarily due to poor performance in MethodHandle.asCollector: #6630.

Benchmark numbers using just this branch improve for 1-3 arguments but then the indy numbers drastically fall off due to #6630 (see benchmark there).

No indy, before:

              dig-01     38.572M (± 4.8%) i/s -    195.184M in   5.072156s
              dig-02     40.883M (± 9.2%) i/s -    202.908M in   5.019322s
              dig-03     29.216M (± 6.0%) i/s -    147.446M in   5.067869s
              dig-04     24.229M (±14.5%) i/s -    116.700M in   5.008082s
              dig-05     21.963M (± 3.0%) i/s -    110.112M in   5.018112s
              dig-06     19.876M (± 3.9%) i/s -     99.521M in   5.014908s
              dig-07     17.807M (± 6.0%) i/s -     90.336M in   5.096993s
              dig-08     16.079M (± 5.5%) i/s -     80.465M in   5.021685s
              dig-09     14.032M (± 6.0%) i/s -     70.755M in   5.062774s
              dig-10     13.674M (± 4.9%) i/s -     69.170M in   5.070931s

Indy, before:

              dig-01     22.006M (± 7.5%) i/s -    109.948M in   5.026393s
              dig-02     20.545M (± 5.0%) i/s -    104.253M in   5.087895s
              dig-03     17.492M (± 7.7%) i/s -     88.326M in   5.083337s
              dig-04     15.416M (± 8.5%) i/s -     76.567M in   5.009796s
              dig-05     10.026M (±17.8%) i/s -     49.617M in   5.112008s
              dig-06      6.033M (±28.6%) i/s -     28.628M in   5.207503s
              dig-07      8.400M (±22.2%) i/s -     40.710M in   5.145922s
              dig-08      6.176M (±23.2%) i/s -     29.795M in   5.026196s
              dig-09      5.184M (±10.3%) i/s -     26.370M in   5.141858s
              dig-10      4.955M (± 7.4%) i/s -     24.656M in   5.004148s

No indy, after:

              dig-01     44.564M (±11.3%) i/s -    222.821M in   5.071922s
              dig-02     42.557M (±10.0%) i/s -    211.797M in   5.033207s
              dig-03     29.046M (±19.0%) i/s -    138.995M in   5.008805s
              dig-04     23.889M (±16.5%) i/s -    115.952M in   5.003884s
              dig-05     10.731M (±36.0%) i/s -     47.529M in   5.027489s
              dig-06     19.317M (±18.7%) i/s -     93.677M in   5.075702s
              dig-07     19.467M (±12.1%) i/s -     97.240M in   5.081109s
              dig-08     17.968M (± 9.0%) i/s -     88.934M in   5.000420s
              dig-09     16.856M (± 5.8%) i/s -     84.081M in   5.006363s
              dig-10     14.803M (± 8.0%) i/s -     74.603M in   5.072760s

Indy, after:

              dig-01     81.816M (±12.0%) i/s -    400.972M in   4.999073s
              dig-02     69.296M (± 7.5%) i/s -    348.541M in   5.060798s
              dig-03     55.133M (± 6.2%) i/s -    277.685M in   5.056766s
              dig-04     15.309M (±23.1%) i/s -     66.131M in   5.061833s
              dig-05     14.798M (± 6.9%) i/s -     74.706M in   5.073418s
              dig-06     14.220M (± 7.3%) i/s -     71.180M in   5.036140s
              dig-07     12.885M (± 5.4%) i/s -     64.917M in   5.052570s
              dig-08     12.701M (± 5.8%) i/s -     63.740M in   5.039548s
              dig-09     10.996M (± 8.0%) i/s -     55.575M in   5.088719s
              dig-10     10.494M (± 9.6%) i/s -     52.704M in   5.079754s

This avoids recursing for known types, which could arbitrarily
deepen the stack and cause an overflow for a deeply-nested
structure. Should also aid performance and inlining.
@headius headius added this to the JRuby milestone Mar 26, 2021
@enebo enebo merged commit 63fcfc7 into jruby:jruby-9.2 Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants