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

WIP: reduce number of memory allocations for small arrays #5339

Closed
wants to merge 2 commits into from

Conversation

ahorek
Copy link
Contributor

@ahorek ahorek commented Oct 1, 2018

@enebo
Copy link
Member

enebo commented Oct 1, 2018

It would be nice to see some numbers on whether we see an improvement. The MRI one was pretty impressive.

@ahorek
Copy link
Contributor Author

ahorek commented Oct 1, 2018

Memory allocations are lower which is good, because a temporal hash is eliminated.
Unfortunatelly the performance is worse right now.

@ahorek
Copy link
Contributor Author

ahorek commented Oct 1, 2018

ok, some numbers...
SMALL_ARRAY_LEN = 16;

sometimes there's an improvement, but it's barely measurable

[] & []

  ruby jruby jruby + patch %
0 35554000 24441000 28369000 1,16071355509185
1 13169000 10024000 12121000 1,20919792498005
2 6219000 5001000 5864000 1,17256548690262
3 3666000 2559000 3123000 1,22039859320047
4 2231000 1457000 1792000 1,2299245024022
5 1346000 880688 1175000 1,33418418327489
6 863701 583015 689860 1,18326286630704
7 570387 399604 440374 1,10202600574569
8 407139 278047 318386 1,14507978866882
9 284940 206697 215885 1,04445154017717
10 209342 151162 158151 1,0462351649224
11 170808 116143 118439 1,01976873337179
12 129906 92273 81156 0,879520553141222
13 105777 72398 68097 0,940592281554739
14 82757 57949 53604 0,925020276449982
15 66192 47993 42500 0,885545808763778
16 52800 39922 34837 0,87262662191273
17 40500 38826 29763 0,76657394529439
18 30558 28679 27158 0,946964677987377
19 25138 25100 24078 0,959282868525896
20 25158 20322 19534 0,961224288947938
21 21232 18726 17861 0,953807540318274
22 18738 16261 15806 0,972018941024537
23 16376 14438 14196 0,983238675716858
24 14636 12948 13031 1,00641025641026

[] | []

  ruby jruby jruby + patch %
0 35554000 25322000 27112000 1,07068951899534
1 12636000 9480000 9912000 1,04556962025316
2 5576000 3887000 4183000 1,07615127347569
3 2917000 1859000 2334000 1,25551371705218
4 1495000 969750 1319000 1,36014436710492
5 813476 584150 804019 1,37639133784131
6 453121 362882 497661 1,37141274574104
7 311763 249077 330834 1,32823986156891
8 217484 177372 229665 1,29482105405588
9 154116 121757 154985 1,27290422727235
10 109070 90970 113200 1,24436627459602
11 86039 65846 77309 1,17408802357015
12 68061 53748 57904 1,07732380739748
13 56917 42492 48984 1,15278170008472
14 43443 34167 39440 1,15433020165657
15 37114 28468 32558 1,14367008571027
16 30899 23757 27424 1,15435450604032
17 25172 20346 22481 1,10493463088568
18 17425 17149 20066 1,17009738177153
19 17348 15098 17149 1,13584580739171

[] - []

  ruby jruby jruby + patch %
0 33935000 21286000 26803000 1,25918444047731
1 12826000 8545000 10774000 1,26085430076068
2 6256000 4011200 4860000 1,21160749900279
3 3515000 2234000 2653000 1,18755595344673
4 1990000 1339000 1530000 1,14264376400299
5 1244000 842235 975713 1,15848070906576
6 692332 567017 606951 1,07042822349242
7 492789 392102 397339 1,01335621853497
8 340891 289671 281012 0,970107466746758
9 241869 220846 190442 0,862329406011429
10 189642 165736 139898 0,844101462566974
11 136925 130937 100724 0,769255443457541
12 114080 100648 73477 0,730039345044114
13 95285 81554 61412 0,753022537214606
14 75485 65883 48011 0,728731235675364
15 62595 52798 37704 0,714117959013599
16 50099 45257 30170 0,666637205294209
17 39847 38217 26151 0,684276630818746
18 28088 33046 23429 0,708981419839012
19 27291 28186 20947 0,743170368267935

memory profile & (org.jruby.RubyHash is gone)

jruby

    1 21,77% 21,77%  34050240 425628  96789840 1209873 474928 org.jruby.runtime.builtin.IRubyObject[]
    2 17,41% 39,18%  27240192 425628  77431872 1209873 474927 org.jruby.RubyHash
    3 13,06% 52,24%  20430144 425628  58073904 1209873 474929 int[]
    4  6,91% 59,15%  10806768 225141  30716928 639936 474935 org.jruby.RubyArray
    5  6,53% 65,68%  10215048 425627  29006472 1208603 474996 org.jruby.runtime.builtin.IRubyObject[]
    6  6,53% 72,21%  10215048 425627  29006472 1208603 474997 org.jruby.runtime.builtin.IRubyObject[]
    7  5,61% 77,82%   8780576 225141  24957504 639936 474936 org.jruby.runtime.builtin.IRubyObject[]
    8  2,27% 80,08%   3545424 73863  10078704 209973 474930 org.jruby.RubyArray
    9  2,14% 82,22%   3348520 59795   9519048 169983 474933 org.jruby.specialized.RubyArrayTwoObject
   10  2,05% 84,28%   3207792 66829   9119088 189981 474931 org.jruby.specialized.RubyArrayOneObject

patch

    1 13,37% 13,37%   7699488 160406  30716928 639936 474844 org.jruby.RubyArray
    2 12,64% 26,00%   7278072 303253  29006472 1208603 474905 org.jruby.runtime.builtin.IRubyObject[]
    3 12,64% 38,64%   7278072 303253  29006472 1208603 474906 org.jruby.runtime.builtin.IRubyObject[]
    4 10,86% 49,50%   6255952 160406  24957504 639936 474845 org.jruby.runtime.builtin.IRubyObject[]
    5  4,39% 53,88%   2526144 52628  10078704 209973 474839 org.jruby.RubyArray
    6  4,14% 58,02%   2385824 42604   9519048 169983 474842 org.jruby.specialized.RubyArrayTwoObject
    7  3,97% 61,99%   2285568 47616   9119088 189981 474840 org.jruby.specialized.RubyArrayOneObject

@ahorek ahorek closed this Oct 2, 2018
@enebo enebo added this to the Invalid or Duplicate milestone Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants