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

dgram: fix possibly deoptimizing use of arguments #11242

Closed
wants to merge 1 commit into from
Closed

dgram: fix possibly deoptimizing use of arguments #11242

wants to merge 1 commit into from

Conversation

vsemozhetbyt
Copy link
Contributor

Checklist
  • vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

dgram

Socket.prototype.bind() could be called without any parameters, so these two argumets[i] access could be out of bounds and in some cases, they could possibly cause deoptimizations.

See #10323 and this comment.

Simple benchmarks show no performance degradation after these fixes:

Before the fixes (click me):
Release\node.exe benchmark/run.js dgram

dgram\array-vs-concat.js
dgram\array-vs-concat.js dur=5 type="concat" chunks=1 num=100 len=64: 0.020413423614270235
dgram\array-vs-concat.js dur=5 type="multi" chunks=1 num=100 len=64: 0.021318266009095838
dgram\array-vs-concat.js dur=5 type="concat" chunks=2 num=100 len=64: 0.019609797889062242
dgram\array-vs-concat.js dur=5 type="multi" chunks=2 num=100 len=64: 0.019302305834389945
dgram\array-vs-concat.js dur=5 type="concat" chunks=4 num=100 len=64: 0.01900702749359504
dgram\array-vs-concat.js dur=5 type="multi" chunks=4 num=100 len=64: 0.01977512456652689
dgram\array-vs-concat.js dur=5 type="concat" chunks=8 num=100 len=64: 0.01851072553812215
dgram\array-vs-concat.js dur=5 type="multi" chunks=8 num=100 len=64: 0.017478000829858897
dgram\array-vs-concat.js dur=5 type="concat" chunks=1 num=100 len=256: 0.07938080698605825
dgram\array-vs-concat.js dur=5 type="multi" chunks=1 num=100 len=256: 0.0855544579455885
dgram\array-vs-concat.js dur=5 type="concat" chunks=2 num=100 len=256: 0.07881817147108744
dgram\array-vs-concat.js dur=5 type="multi" chunks=2 num=100 len=256: 0.0832426052123247
dgram\array-vs-concat.js dur=5 type="concat" chunks=4 num=100 len=256: 0.07797182769977243
dgram\array-vs-concat.js dur=5 type="multi" chunks=4 num=100 len=256: 0.07792084119847094
dgram\array-vs-concat.js dur=5 type="concat" chunks=8 num=100 len=256: 0.07242495183569352
dgram\array-vs-concat.js dur=5 type="multi" chunks=8 num=100 len=256: 0.0696691928137009
dgram\array-vs-concat.js dur=5 type="concat" chunks=1 num=100 len=512: 0.15721200435278507
dgram\array-vs-concat.js dur=5 type="multi" chunks=1 num=100 len=512: 0.16872753136365387
dgram\array-vs-concat.js dur=5 type="concat" chunks=2 num=100 len=512: 0.15311587573130966
dgram\array-vs-concat.js dur=5 type="multi" chunks=2 num=100 len=512: 0.16432945990120004
dgram\array-vs-concat.js dur=5 type="concat" chunks=4 num=100 len=512: 0.14867930449630173
dgram\array-vs-concat.js dur=5 type="multi" chunks=4 num=100 len=512: 0.15411421586943283
dgram\array-vs-concat.js dur=5 type="concat" chunks=8 num=100 len=512: 0.14246760509260645
dgram\array-vs-concat.js dur=5 type="multi" chunks=8 num=100 len=512: 0.1400713009510874
dgram\array-vs-concat.js dur=5 type="concat" chunks=1 num=100 len=1024: 0.30470850422160667
dgram\array-vs-concat.js dur=5 type="multi" chunks=1 num=100 len=1024: 0.34434221844106455
dgram\array-vs-concat.js dur=5 type="concat" chunks=2 num=100 len=1024: 0.2936385315600058
dgram\array-vs-concat.js dur=5 type="multi" chunks=2 num=100 len=1024: 0.33183344658041314
dgram\array-vs-concat.js dur=5 type="concat" chunks=4 num=100 len=1024: 0.29042121350964345
dgram\array-vs-concat.js dur=5 type="multi" chunks=4 num=100 len=1024: 0.3063331945971229
dgram\array-vs-concat.js dur=5 type="concat" chunks=8 num=100 len=1024: 0.27943412975786086
dgram\array-vs-concat.js dur=5 type="multi" chunks=8 num=100 len=1024: 0.2784225109326032

dgram\multi-buffer.js
dgram\multi-buffer.js dur=5 type="send" chunks=1 num=100 len=64: 0.02109223689568203
dgram\multi-buffer.js dur=5 type="recv" chunks=1 num=100 len=64: 0.00021308793192767727
dgram\multi-buffer.js dur=5 type="send" chunks=2 num=100 len=64: 0.020769684203563888
dgram\multi-buffer.js dur=5 type="recv" chunks=2 num=100 len=64: 0.00020998096567558024
dgram\multi-buffer.js dur=5 type="send" chunks=4 num=100 len=64: 0.019055577450296804
dgram\multi-buffer.js dur=5 type="recv" chunks=4 num=100 len=64: 0.00019089016428317388
dgram\multi-buffer.js dur=5 type="send" chunks=8 num=100 len=64: 0.017463130851958403
dgram\multi-buffer.js dur=5 type="recv" chunks=8 num=100 len=64: 0.00016713763827638084
dgram\multi-buffer.js dur=5 type="send" chunks=1 num=100 len=256: 0.07621227958382061
dgram\multi-buffer.js dur=5 type="recv" chunks=1 num=100 len=256: 0.000786385696591585
dgram\multi-buffer.js dur=5 type="send" chunks=2 num=100 len=256: 0.07953054364342717
dgram\multi-buffer.js dur=5 type="recv" chunks=2 num=100 len=256: 0.000822598733015174
dgram\multi-buffer.js dur=5 type="send" chunks=4 num=100 len=256: 0.07772456562145642
dgram\multi-buffer.js dur=5 type="recv" chunks=4 num=100 len=256: 0.0007808260317662278
dgram\multi-buffer.js dur=5 type="send" chunks=8 num=100 len=256: 0.07101652936095898
dgram\multi-buffer.js dur=5 type="recv" chunks=8 num=100 len=256: 0.0006966008157853522
dgram\multi-buffer.js dur=5 type="send" chunks=1 num=100 len=1024: 0.3328152160090698
dgram\multi-buffer.js dur=5 type="recv" chunks=1 num=100 len=1024: 0.0034209370041683894
dgram\multi-buffer.js dur=5 type="send" chunks=2 num=100 len=1024: 0.32470062459007615
dgram\multi-buffer.js dur=5 type="recv" chunks=2 num=100 len=1024: 0.003283094375923841
dgram\multi-buffer.js dur=5 type="send" chunks=4 num=100 len=1024: 0.30292024861897976
dgram\multi-buffer.js dur=5 type="recv" chunks=4 num=100 len=1024: 0.0030532452230243104
dgram\multi-buffer.js dur=5 type="send" chunks=8 num=100 len=1024: 0.2830325958167614
dgram\multi-buffer.js dur=5 type="recv" chunks=8 num=100 len=1024: 0.002782114387379061

dgram\offset-length.js
dgram\offset-length.js dur=5 type="send" num=100 len=1: 0.0003186605782046186
dgram\offset-length.js dur=5 type="recv" num=100 len=1: 0.0000031769599503666797
dgram\offset-length.js dur=5 type="send" num=100 len=64: 0.020222469566660867
dgram\offset-length.js dur=5 type="recv" num=100 len=64: 0.0002057548934626847
dgram\offset-length.js dur=5 type="send" num=100 len=256: 0.08161113157755215
dgram\offset-length.js dur=5 type="recv" num=100 len=256: 0.0008216365582010693
dgram\offset-length.js dur=5 type="send" num=100 len=1024: 0.32363771818021053
dgram\offset-length.js dur=5 type="recv" num=100 len=1024: 0.003236732567751061

dgram\single-buffer.js
dgram\single-buffer.js dur=5 type="send" num=100 len=1: 0.0003342798746881872
dgram\single-buffer.js dur=5 type="recv" num=100 len=1: 0.0000033101247505441493
dgram\single-buffer.js dur=5 type="send" num=100 len=64: 0.02125277483374607
dgram\single-buffer.js dur=5 type="recv" num=100 len=64: 0.0002109600303668221
dgram\single-buffer.js dur=5 type="send" num=100 len=256: 0.08510005742141984
dgram\single-buffer.js dur=5 type="recv" num=100 len=256: 0.0008434335153269099
dgram\single-buffer.js dur=5 type="send" num=100 len=1024: 0.34175360960982193
dgram\single-buffer.js dur=5 type="recv" num=100 len=1024: 0.0033519836980728415
After the fixes (click me):
Release\node.exe benchmark/run.js dgram

dgram\array-vs-concat.js
dgram\array-vs-concat.js dur=5 type="concat" chunks=1 num=100 len=64: 0.019998298310699464
dgram\array-vs-concat.js dur=5 type="multi" chunks=1 num=100 len=64: 0.020904479923743967
dgram\array-vs-concat.js dur=5 type="concat" chunks=2 num=100 len=64: 0.019426704035245376
dgram\array-vs-concat.js dur=5 type="multi" chunks=2 num=100 len=64: 0.02046648568936641
dgram\array-vs-concat.js dur=5 type="concat" chunks=4 num=100 len=64: 0.01960815187460356
dgram\array-vs-concat.js dur=5 type="multi" chunks=4 num=100 len=64: 0.019201306011310242
dgram\array-vs-concat.js dur=5 type="concat" chunks=8 num=100 len=64: 0.018536654183278375
dgram\array-vs-concat.js dur=5 type="multi" chunks=8 num=100 len=64: 0.01757510205628739
dgram\array-vs-concat.js dur=5 type="concat" chunks=1 num=100 len=256: 0.08034578243828928
dgram\array-vs-concat.js dur=5 type="multi" chunks=1 num=100 len=256: 0.08519467597300402
dgram\array-vs-concat.js dur=5 type="concat" chunks=2 num=100 len=256: 0.07898968697148778
dgram\array-vs-concat.js dur=5 type="multi" chunks=2 num=100 len=256: 0.08293523756844151
dgram\array-vs-concat.js dur=5 type="concat" chunks=4 num=100 len=256: 0.07538359651203853
dgram\array-vs-concat.js dur=5 type="multi" chunks=4 num=100 len=256: 0.07822343326554314
dgram\array-vs-concat.js dur=5 type="concat" chunks=8 num=100 len=256: 0.07283978673371065
dgram\array-vs-concat.js dur=5 type="multi" chunks=8 num=100 len=256: 0.07053324621949313
dgram\array-vs-concat.js dur=5 type="concat" chunks=1 num=100 len=512: 0.15340200560018824
dgram\array-vs-concat.js dur=5 type="multi" chunks=1 num=100 len=512: 0.16960205295424957
dgram\array-vs-concat.js dur=5 type="concat" chunks=2 num=100 len=512: 0.151996097230419
dgram\array-vs-concat.js dur=5 type="multi" chunks=2 num=100 len=512: 0.16555537538214277
dgram\array-vs-concat.js dur=5 type="concat" chunks=4 num=100 len=512: 0.14713204203132063
dgram\array-vs-concat.js dur=5 type="multi" chunks=4 num=100 len=512: 0.15214141468659234
dgram\array-vs-concat.js dur=5 type="concat" chunks=8 num=100 len=512: 0.14297984421232035
dgram\array-vs-concat.js dur=5 type="multi" chunks=8 num=100 len=512: 0.14285304254474696
dgram\array-vs-concat.js dur=5 type="concat" chunks=1 num=100 len=1024: 0.3082238531303529
dgram\array-vs-concat.js dur=5 type="multi" chunks=1 num=100 len=1024: 0.3361665646123714
dgram\array-vs-concat.js dur=5 type="concat" chunks=2 num=100 len=1024: 0.294009967416119
dgram\array-vs-concat.js dur=5 type="multi" chunks=2 num=100 len=1024: 0.32938506370801257
dgram\array-vs-concat.js dur=5 type="concat" chunks=4 num=100 len=1024: 0.2864018671443685
dgram\array-vs-concat.js dur=5 type="multi" chunks=4 num=100 len=1024: 0.31041893053693237
dgram\array-vs-concat.js dur=5 type="concat" chunks=8 num=100 len=1024: 0.27774562208741815
dgram\array-vs-concat.js dur=5 type="multi" chunks=8 num=100 len=1024: 0.2815659463416438

dgram\multi-buffer.js
dgram\multi-buffer.js dur=5 type="send" chunks=1 num=100 len=64: 0.02133989201632066
dgram\multi-buffer.js dur=5 type="recv" chunks=1 num=100 len=64: 0.00021426996651214555
dgram\multi-buffer.js dur=5 type="send" chunks=2 num=100 len=64: 0.020489658144534215
dgram\multi-buffer.js dur=5 type="recv" chunks=2 num=100 len=64: 0.00020654497899215277
dgram\multi-buffer.js dur=5 type="send" chunks=4 num=100 len=64: 0.019427196594262293
dgram\multi-buffer.js dur=5 type="recv" chunks=4 num=100 len=64: 0.00019346245583245347
dgram\multi-buffer.js dur=5 type="send" chunks=8 num=100 len=64: 0.017423741845451392
dgram\multi-buffer.js dur=5 type="recv" chunks=8 num=100 len=64: 0.0001772565741828839
dgram\multi-buffer.js dur=5 type="send" chunks=1 num=100 len=256: 0.08348197207417823
dgram\multi-buffer.js dur=5 type="recv" chunks=1 num=100 len=256: 0.0008519555090428148
dgram\multi-buffer.js dur=5 type="send" chunks=2 num=100 len=256: 0.08416651660960886
dgram\multi-buffer.js dur=5 type="recv" chunks=2 num=100 len=256: 0.0008262619526430367
dgram\multi-buffer.js dur=5 type="send" chunks=4 num=100 len=256: 0.07613223548983997
dgram\multi-buffer.js dur=5 type="recv" chunks=4 num=100 len=256: 0.0007724666359888078
dgram\multi-buffer.js dur=5 type="send" chunks=8 num=100 len=256: 0.07022821961092969
dgram\multi-buffer.js dur=5 type="recv" chunks=8 num=100 len=256: 0.0007028155301349925
dgram\multi-buffer.js dur=5 type="send" chunks=1 num=100 len=1024: 0.33990335582138237
dgram\multi-buffer.js dur=5 type="recv" chunks=1 num=100 len=1024: 0.0033347779207178047
dgram\multi-buffer.js dur=5 type="send" chunks=2 num=100 len=1024: 0.33114827659574847
dgram\multi-buffer.js dur=5 type="recv" chunks=2 num=100 len=1024: 0.0032325424185883026
dgram\multi-buffer.js dur=5 type="send" chunks=4 num=100 len=1024: 0.3056387475814086
dgram\multi-buffer.js dur=5 type="recv" chunks=4 num=100 len=1024: 0.0030595000668458276
dgram\multi-buffer.js dur=5 type="send" chunks=8 num=100 len=1024: 0.28056936065128824
dgram\multi-buffer.js dur=5 type="recv" chunks=8 num=100 len=1024: 0.002799337607058917

dgram\offset-length.js
dgram\offset-length.js dur=5 type="send" num=100 len=1: 0.000320474058761629
dgram\offset-length.js dur=5 type="recv" num=100 len=1: 0.0000032165942722401654
dgram\offset-length.js dur=5 type="send" num=100 len=64: 0.020712717203098478
dgram\offset-length.js dur=5 type="recv" num=100 len=64: 0.00020774881433332406
dgram\offset-length.js dur=5 type="send" num=100 len=256: 0.08191056081895902
dgram\offset-length.js dur=5 type="recv" num=100 len=256: 0.0008227156793202832
dgram\offset-length.js dur=5 type="send" num=100 len=1024: 0.32907221457431485
dgram\offset-length.js dur=5 type="recv" num=100 len=1024: 0.003244538888218392

dgram\single-buffer.js
dgram\single-buffer.js dur=5 type="send" num=100 len=1: 0.00033545141368716293
dgram\single-buffer.js dur=5 type="recv" num=100 len=1: 0.0000033181468268436883
dgram\single-buffer.js dur=5 type="send" num=100 len=64: 0.021114216973934095
dgram\single-buffer.js dur=5 type="recv" num=100 len=64: 0.00020900284156453758
dgram\single-buffer.js dur=5 type="send" num=100 len=256: 0.08428150916647331
dgram\single-buffer.js dur=5 type="recv" num=100 len=256: 0.0008478502422047072
dgram\single-buffer.js dur=5 type="send" num=100 len=1024: 0.3420805345205732
dgram\single-buffer.js dur=5 type="recv" num=100 len=1024: 0.003354160146381448

@nodejs-github-bot nodejs-github-bot added the dgram Issues and PRs related to the dgram subsystem / UDP. label Feb 8, 2017
@Fishrock123
Copy link
Contributor

@cjihrig
Copy link
Contributor

cjihrig commented Feb 8, 2017

Simple benchmarks show no performance degradation after these fixes

Are you seeing performance improvements?

Can you display the benchmarking results in a more readable way? This is a lot of text to jump back and forth in.

@vsemozhetbyt
Copy link
Contributor Author

vsemozhetbyt commented Feb 8, 2017

@cjihrig Sorry, I am not very good at Node.js benchmarks and I has not Rscript on my machine to get the proper comparison. Could I present results in some another way?

I don't think we could see any performance improvements in common cases, and I am not a heavy user of dgram module to imagine valid use cases to see these performance improvements. Maybe, somebody else could?

FWIW, this is some weird test example (partly taken from socket.bind() doc) to get deopt:

const dgram = require('dgram');

for (let i = 0; i < 1000; i++) {
  const server = dgram.createSocket('udp4');
  server.on('listening', () => {
    const address = server.address();
    console.log(`server listening ${address.address}:${address.port}`);
  });
  server.bind();
}
node --trace_opt --trace_deopt test.js | findstr bind

Before the fixes:

[marking 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)> for optimized recompilation, reason: hot and stable, ICs with typeinfo: 15/34 (44%), generic ICs: 3/34 (8%)]
[compiling method 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)> using Crankshaft]
[optimizing 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)> - took 0.000, 0.000, 0.000 ms]
[completed optimizing 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)>]
[deoptimizing (DEOPT eager): begin 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)> (opt #9) @16, FP to SP delta: 68, caller sp: 0x0038ee2c]
  reading input frame Socket.bind => node=120, args=2, height=5; inputs:
      0: 0x19b90a19 ; [fp - 8] 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)>
  translating frame Socket.bind => node=120, height=16
    0x0038ee14: [top + 16] <- 0x19b90a19 ;  function    19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)>  (input #0)
[deoptimizing (eager): end 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)> @16 => node=120, pc=0x344c4dce, caller sp=0x0038ee2c, state=TOS_REGISTER, took 16.000 ms]
[removing optimized code for: Socket.bind]
[evicting entry from optimizing code map (notify deoptimized) for 19B8E465 <SharedFunctionInfo Socket.bind>]
[marking 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)> for optimized recompilation, reason: hot and stable, ICs with typeinfo: 15/34 (44%), generic ICs: 3/34 (8%)]
[compiling method 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)> using Crankshaft]
[optimizing 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)> - took 0.000, 0.000, 0.000 ms]
[completed optimizing 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)>]
[deoptimizing (DEOPT eager): begin 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)> (opt #10) @16, FP to SP delta: 68, caller sp: 0x0038ee2c]
  reading input frame Socket.bind => node=120, args=2, height=5; inputs:
      0: 0x19b90a19 ; [fp - 8] 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)>
  translating frame Socket.bind => node=120, height=16
    0x0038ee14: [top + 16] <- 0x19b90a19 ;  function    19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)>  (input #0)
[deoptimizing (eager): end 19B90A19 <JS Function Socket.bind (SharedFunctionInfo 19B8E465)> @16 => node=120, pc=0x344c4dce, caller sp=0x0038ee2c, state=TOS_REGISTER, took 0.000 ms]
[removing optimized code for: Socket.bind]
[evicting entry from optimizing code map (notify deoptimized) for 19B8E465 <SharedFunctionInfo Socket.bind>]

After the fixes:

[marking 3E110A19 <JS Function Socket.bind (SharedFunctionInfo 3E10E465)> for optimized recompilation, reason: hot and stable, ICs with typeinfo: 17/38 (44%), generic ICs: 0/38 (0%)]
[compiling method 3E110A19 <JS Function Socket.bind (SharedFunctionInfo 3E10E465)> using Crankshaft]
[optimizing 3E110A19 <JS Function Socket.bind (SharedFunctionInfo 3E10E465)> - took 0.000, 0.000, 0.000 ms]
[completed optimizing 3E110A19 <JS Function Socket.bind (SharedFunctionInfo 3E10E465)>]
[deoptimizer unlinked: Socket.bind / 3e110a19]
[evicting entry from optimizing code map (deoptimized code) for 3E10E465 <SharedFunctionInfo Socket.bind>]

@cjihrig
Copy link
Contributor

cjihrig commented Feb 8, 2017

I haven't benchmarked, but you could do this to avoid using arguments in the address calculation.

Using arguments for the callback like you currently are seems like the simplest way to go, since it can be in a number of locations.

@vsemozhetbyt
Copy link
Contributor Author

@cjihrig Should I amend with address_ ?

Sorry, could you explain the second sentence some more, please?

@cjihrig
Copy link
Contributor

cjihrig commented Feb 8, 2017

Sorry, I was just saying, we could use _address instead of arguments if benchmarking shows it's OK. The second sentence was basically that your first change on line 145 LGTM.

@vsemozhetbyt
Copy link
Contributor Author

@cjihrig I've amended the second change, build and tests pass. I've installed R and have launched the node benchmark/compare.js ... dgram ... phase. It proceeds very slowly (5% only for ~40 min). Maybe we could run another CI meanwhile?

@vsemozhetbyt
Copy link
Contributor Author

Benchmarks results:
                                                                         improvement confidence     p.value
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=1 num=100 len=1024     -0.07 %            0.819142606
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=1 num=100 len=256       0.65 %          * 0.029980094
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=1 num=100 len=512       0.53 %            0.105329248
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=1 num=100 len=64       -0.15 %            0.539509788
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=2 num=100 len=1024     -0.04 %            0.877992589
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=2 num=100 len=256      -0.42 %            0.224659267
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=2 num=100 len=512      -0.35 %            0.200748080
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=2 num=100 len=64       -0.55 %            0.123158638
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=4 num=100 len=1024     -0.31 %            0.241236440
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=4 num=100 len=256      -0.00 %            0.999443074
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=4 num=100 len=512      -0.14 %            0.592581146
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=4 num=100 len=64       -0.84 %          * 0.021566262
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=8 num=100 len=1024     -0.33 %            0.236997003
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=8 num=100 len=256       0.02 %            0.943577183
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=8 num=100 len=512      -0.44 %            0.093730052
 dgram\\array-vs-concat.js dur=5 type="concat" chunks=8 num=100 len=64       -0.28 %            0.289756919
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=1 num=100 len=1024       0.44 %            0.060660498
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=1 num=100 len=256        0.25 %            0.320558233
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=1 num=100 len=512        0.39 %            0.177161838
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=1 num=100 len=64         0.36 %            0.182711880
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=2 num=100 len=1024       0.12 %            0.613099185
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=2 num=100 len=256        0.19 %            0.504940429
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=2 num=100 len=512        0.12 %            0.678952500
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=2 num=100 len=64        -0.16 %            0.459314273
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=4 num=100 len=1024       0.53 %            0.088714998
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=4 num=100 len=256        0.72 %          * 0.030422914
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=4 num=100 len=512        0.40 %            0.184751838
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=4 num=100 len=64         0.29 %            0.320490675
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=8 num=100 len=1024       0.40 %            0.135630861
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=8 num=100 len=256        0.42 %            0.093813494
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=8 num=100 len=512        0.25 %            0.303448782
 dgram\\array-vs-concat.js dur=5 type="multi" chunks=8 num=100 len=64         0.22 %            0.333867175
 dgram\\multi-buffer.js dur=5 type="recv" chunks=1 num=100 len=1024          -0.52 %            0.051782242
 dgram\\multi-buffer.js dur=5 type="recv" chunks=1 num=100 len=256           -0.25 %            0.200875743
 dgram\\multi-buffer.js dur=5 type="recv" chunks=1 num=100 len=64            -0.36 %            0.156919544
 dgram\\multi-buffer.js dur=5 type="recv" chunks=2 num=100 len=1024          -0.65 %         ** 0.009810655
 dgram\\multi-buffer.js dur=5 type="recv" chunks=2 num=100 len=256           -0.32 %            0.216226970
 dgram\\multi-buffer.js dur=5 type="recv" chunks=2 num=100 len=64             0.00 %            0.998397455
 dgram\\multi-buffer.js dur=5 type="recv" chunks=4 num=100 len=1024          -0.30 %            0.293122198
 dgram\\multi-buffer.js dur=5 type="recv" chunks=4 num=100 len=256           -0.30 %            0.369189963
 dgram\\multi-buffer.js dur=5 type="recv" chunks=4 num=100 len=64             0.34 %            0.394163637
 dgram\\multi-buffer.js dur=5 type="recv" chunks=8 num=100 len=1024           0.05 %            0.854895663
 dgram\\multi-buffer.js dur=5 type="recv" chunks=8 num=100 len=256            0.45 %            0.070950431
 dgram\\multi-buffer.js dur=5 type="recv" chunks=8 num=100 len=64             0.55 %            0.053218194
 dgram\\multi-buffer.js dur=5 type="send" chunks=1 num=100 len=1024          -0.23 %            0.369869995
 dgram\\multi-buffer.js dur=5 type="send" chunks=1 num=100 len=256           -0.45 %          * 0.037902697
 dgram\\multi-buffer.js dur=5 type="send" chunks=1 num=100 len=64            -0.47 %            0.096614111
 dgram\\multi-buffer.js dur=5 type="send" chunks=2 num=100 len=1024          -0.29 %            0.270257446
 dgram\\multi-buffer.js dur=5 type="send" chunks=2 num=100 len=256           -0.16 %            0.539737074
 dgram\\multi-buffer.js dur=5 type="send" chunks=2 num=100 len=64            -0.39 %            0.110370236
 dgram\\multi-buffer.js dur=5 type="send" chunks=4 num=100 len=1024          -0.19 %            0.597112456
 dgram\\multi-buffer.js dur=5 type="send" chunks=4 num=100 len=256           -0.29 %            0.308934876
 dgram\\multi-buffer.js dur=5 type="send" chunks=4 num=100 len=64            -0.08 %            0.796715902
 dgram\\multi-buffer.js dur=5 type="send" chunks=8 num=100 len=1024           0.56 %          * 0.036801865
 dgram\\multi-buffer.js dur=5 type="send" chunks=8 num=100 len=256           -0.01 %            0.974705939
 dgram\\multi-buffer.js dur=5 type="send" chunks=8 num=100 len=64             0.64 %          * 0.016531293
 dgram\\offset-length.js dur=5 type="recv" num=100 len=1                     -3.16 %            0.084384305
 dgram\\offset-length.js dur=5 type="recv" num=100 len=1024                  -0.60 %            0.358465196
 dgram\\offset-length.js dur=5 type="recv" num=100 len=256                    0.03 %            0.972613434
 dgram\\offset-length.js dur=5 type="recv" num=100 len=64                    -1.05 %          * 0.033493587
 dgram\\offset-length.js dur=5 type="send" num=100 len=1                     -1.74 %            0.051167510
 dgram\\offset-length.js dur=5 type="send" num=100 len=1024                   0.06 %            0.963471910
 dgram\\offset-length.js dur=5 type="send" num=100 len=256                   -0.63 %            0.342649711
 dgram\\offset-length.js dur=5 type="send" num=100 len=64                    -0.21 %            0.741684095
 dgram\\single-buffer.js dur=5 type="recv" num=100 len=1                      0.26 %            0.532516397
 dgram\\single-buffer.js dur=5 type="recv" num=100 len=1024                   0.24 %            0.609156242
 dgram\\single-buffer.js dur=5 type="recv" num=100 len=256                   -0.22 %            0.409761765
 dgram\\single-buffer.js dur=5 type="recv" num=100 len=64                    -0.04 %            0.909745426
 dgram\\single-buffer.js dur=5 type="send" num=100 len=1                     -0.17 %            0.674389873
 dgram\\single-buffer.js dur=5 type="send" num=100 len=1024                  -0.56 %            0.117767197
 dgram\\single-buffer.js dur=5 type="send" num=100 len=256                    0.70 %            0.394189582
 dgram\\single-buffer.js dur=5 type="send" num=100 len=64                     0.29 %            0.434809490

@vsemozhetbyt
Copy link
Contributor Author

vsemozhetbyt commented Feb 10, 2017

@cjihrig @Fishrock123
It seems the current benchmarks could not show any improvements because Socket.prototype.bind() is called only once per run in them, so it is not optimized/deoptimized at all (and it is always called with one parameter). However, if I run this test with the both node.exe, I can see consistent +20% after the fix:

'use strict';

const dgram = require('dgram');

console.time('bind');
for (let i = 0; i < 1e4; i++) dgram.createSocket('udp4').bind();
console.timeEnd('bind');

node.exe before the fix: ~100 ms
node.exe after the fix: ~80 ms

@cjihrig
Copy link
Contributor

cjihrig commented Feb 10, 2017

@vsemozhetbyt sounds good to me. It might be worth adding a new benchmark for bind() in a separate PR.

@vsemozhetbyt
Copy link
Contributor Author

There was a conflict with the recent #11243, so I've resolved it in the GitHub. But this has added a merge commit. Is it OK? Will it be squashed? Or should I resolve in another way next time in conflict case?

@cjihrig
Copy link
Contributor

cjihrig commented Feb 10, 2017

Can you squash it please.

@addaleax
Copy link
Member

Is it OK? Will it be squashed?

Yes. :)

Or should I resolve in another way next time in conflict case?

It would probably be easiest for everyone if you git rebase to resolve conflicts, if you feel comfortable doing that.

@vsemozhetbyt
Copy link
Contributor Author

Sorry, I've messed up one of the previous PRs in similar circumstances, attempting to rebase. Is there a guide for this case?

@vsemozhetbyt
Copy link
Contributor Author

@cjihrig
Copy link
Contributor

cjihrig commented Feb 13, 2017

@cjihrig
Copy link
Contributor

cjihrig commented Feb 14, 2017

@vsemozhetbyt here are your changes as a single commit. Can you fix up your branch, and I'll run the CI again.

@vsemozhetbyt
Copy link
Contributor Author

vsemozhetbyt commented Feb 14, 2017

@cjihrig I'm afraid I don't know how to do that:( Could you list git commands and edit actions for that? Sorry:(

@cjihrig
Copy link
Contributor

cjihrig commented Feb 14, 2017

@vsemozhetbyt you can get rid of the merge commit using git reset --hard HEAD~1. Then, git pull --rebase origin master (your remote and branch names may vary). You should have to resolve conflicts in lib/dgram.js. Once you finish the rebase, you should have a single commit that shows up as the first entry in git log. You can then push the branch with the --force to update this PR.

@vsemozhetbyt
Copy link
Contributor Author

@cjihrig Thank you. I hope I've done it right.

@cjihrig
Copy link
Contributor

cjihrig commented Feb 14, 2017

Looks good. Thanks. CI: https://ci.nodejs.org/job/node-test-pull-request/6416/

@vsemozhetbyt
Copy link
Contributor Author

@cjihrig Why the test/arm is marked as failure here, but there or there it is marked as 'no failures' or 'Finished: SUCCESS' (also '0 failures , 19 skipped' there)?

@gibfahn
Copy link
Member

gibfahn commented Feb 16, 2017

@vsemozhetbyt The Github bot reporting test/arm as a failure when it's actually passing in CI is an existing issue (that I think has actually just been fixed). If it's green in ci.nodejs.org then it should be fine.

@cjihrig
Copy link
Contributor

cjihrig commented Feb 16, 2017

Landed in adf1ed0. Thanks!

@cjihrig cjihrig closed this Feb 16, 2017
cjihrig pushed a commit that referenced this pull request Feb 16, 2017
This commit adds a guard against an out of bounds access of
arguments, and replaces another use of arguments with a named
function parameter.

Refs: #10323
PR-URL: #11242
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@vsemozhetbyt vsemozhetbyt deleted the dgram-fix-arguments branch February 16, 2017 17:31
@jasnell
Copy link
Member

jasnell commented Feb 16, 2017

@cjihrig @vsemozhetbyt ... it appears that one of the recent dgram related commits that landed today maybe causing some failures in CI in arm (see https://ci.nodejs.org/job/node-test-binary-arm/6233/RUN_SUBSET=1,label=pi1-raspbian-wheezy/console for example). I'm not sure exactly which commit may have done it, but I'm seeing the same failure across multiple independent CI runs.

@cjihrig
Copy link
Contributor

cjihrig commented Feb 16, 2017

The problem seems to be related to the ARM cluster move - nodejs/build#611 (comment).

@ChALkeR ChALkeR mentioned this pull request Feb 17, 2017
2 tasks
italoacasas pushed a commit to italoacasas/node that referenced this pull request Feb 20, 2017
This commit adds a guard against an out of bounds access of
arguments, and replaces another use of arguments with a named
function parameter.

Refs: nodejs#10323
PR-URL: nodejs#11242
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
addaleax pushed a commit that referenced this pull request Feb 21, 2017
italoacasas pushed a commit that referenced this pull request Feb 22, 2017
This commit adds a guard against an out of bounds access of
arguments, and replaces another use of arguments with a named
function parameter.

Refs: #10323
PR-URL: #11242
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
addaleax pushed a commit that referenced this pull request Feb 22, 2017
@italoacasas italoacasas mentioned this pull request Feb 25, 2017
jasnell pushed a commit that referenced this pull request Mar 7, 2017
jasnell pushed a commit that referenced this pull request Mar 7, 2017
jasnell pushed a commit that referenced this pull request Mar 9, 2017
This commit adds a guard against an out of bounds access of
arguments, and replaces another use of arguments with a named
function parameter.

Refs: #10323
PR-URL: #11242
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@jasnell
Copy link
Member

jasnell commented Mar 9, 2017

Landed on v6. Would need a backport PR to land on v4

@vsemozhetbyt
Copy link
Contributor Author

@jasnell PTAL: #11758

MylesBorins pushed a commit that referenced this pull request Mar 9, 2017
MylesBorins pushed a commit that referenced this pull request Mar 9, 2017
This commit adds a guard against an out of bounds access of
arguments, and replaces another use of arguments with a named
function parameter.

Refs: #10323
PR-URL: #11242
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Mar 9, 2017
MylesBorins pushed a commit that referenced this pull request Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dgram Issues and PRs related to the dgram subsystem / UDP.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants