Uh oh!
There was an error while loading. Please reload this page.
net,http2: refactor _write and _writev in net.Socket and http2.Http2Stream - #20643
net,http2: refactor _write and _writev in net.Socket and http2.Http2Stream#20643ryzokuken wants to merge 1 commit into
Conversation
mcollina
commented
May 9, 2018
I'm concerned about making the That logic needs tidy up anyway, so let's find a way to keep the number of arguments consistent. |
ryzokuken
commented
May 10, 2018
@mcollina You mean That said, please share whatever you have in mind and hopefully we would be able to make it a tad faster and simpler. |
mcollina
commented
May 10, 2018
My bad, I misread a |
ryzokuken
commented
May 10, 2018
That's what I did the first time around too 😅, but yeah. They're different functions, so I hope everything is fine, right? Should I proceed? |
A few questions:
-- more to come -- |
ryzokuken
commented
May 10, 2018
okay, tests pass so I'm keeping it here until someone asks me to remove it. One more thing: Why does this.once('connect',functionconnect(){this._writeGeneric(writev,data,encoding,cb);});even though normal functions have their own |
ryzokuken
commented
May 10, 2018
Tests pass again, I'm either making progress, or we have weak test cases. Two things next:
|
ryzokuken
commented
May 10, 2018
Okay, when it comes to the actual logic for refreshing timers, they're both quite similar. In Socket.prototype._unrefTimer=function_unrefTimer(){for(vars=this;s!==null;s=s._parent){if(s[kTimeout])s[kTimeout][refreshFnSymbol]();}};and in [kUpdateTimer](){if(this.destroyed)return;if(this[kTimeout])this[kTimeout][refreshFnSymbol]();if(this[kSession])this[kSession][kUpdateTimer]();}for now, the least I think I could do is switch from the iterative approach in |
ryzokuken
commented
May 10, 2018
Okay, it wasn't recursing, but rather refreshing the associated |
1732c4f to
1257d56CompareCurrent roadblocks (inconsistencies):
|
ryzokuken
commented
May 11, 2018
addaleax
commented
May 14, 2018
Maybe something that we also want in HTTP/2? Anyway, this LGTM as is and I’d be okay with landing this as-is and iterating onwards from there. |
apapirovski
commented
May 14, 2018
I haven't had a chance to fully review but 2 things off the top:
|
ryzokuken
commented
May 14, 2018
While we may not need the properties yet, I believe they could prove helpful while fleshing out future behavior. Anyway, let me know if the added cruft of two simple properties would be worth a little consistency and nifty properties that could be used in the future (or perhaps even right now).
While I think I could just move to a Symbol pretty easily, I don't think it should be a problem because:
That said, if you insist, I will make that change.
Again, I made the change only to make things a tad more consistent, and you have a much better idea that me how this could affect speed in the long term. If you say, I could revert that particular part back to the original. |
apapirovski
commented
May 15, 2018
The fact that _writeGeneric is exposed on the Socket is just bad behaviour we're stuck with — it comes from a time when we didn't have many options for hiding private properties and methods. Now we do and since it's a private implementation detail, it shouldn't leak to the user. As for
I don't think things need to be more consistent between those two functions. I get the point of making _write and _writev more consistent, I don't think any unrelated functions need to be. As far as how it's slower: calling a function (adding it to the stack) is slower than just a loop and since it's now recursive there's no way it can get inlined by V8. |
ryzokuken
commented
May 15, 2018
Get it, loop would definitely be faster. That said, I'm thinking: as long as the two classes each have an exposed function (maybe called
It seems that'll no longer be a problem once I'm done with this (same with it being exposed on |
apapirovski
commented
May 15, 2018
Keep in mind that there would be the same issue with exposing |
@apapirovski could we not expose it but still call it from a base class, somehow? |
ryzokuken
commented
May 16, 2018
@apapirovski@addaleax This looks better, I suppose? |
apapirovski
commented
May 16, 2018
LGTM. Could also be a separate function to avoid the symbol lookup when calling it but this is fine as the first version. _unrefTimer still needs to be reverted. Then we could likely land this and iterate from there. |
ryzokuken
commented
May 16, 2018
@apapirovski reverting |
ryzokuken
commented
May 18, 2018
@BridgeAR okay! In that case, this is ready to merge. Awaiting @apapirovski's explicit approval before landing. |
apapirovski
left a comment
There was a problem hiding this comment.
LGTM. Thanks for working on this!
ryzokuken
commented
May 18, 2018
@apapirovski Thanks for all the constructive feedback and guidance! Will land this today. |
ryzokuken
commented
May 18, 2018
Landing this. |
Refactor writable part (the _write and _writev functions) in net.Socket and http2.Http2Stream classes. Also involves adding a generic "WriteGeneric" method to the Http2Stream class based on net.Socket._writeGeneric, but behind a symbol.
ryzokuken
commented
May 19, 2018
Squashing and running CI, will land in the morning. |
9cf4830 to
334f044Compareryzokuken
commented
May 19, 2018
ryzokuken
commented
May 19, 2018
Landed in a7fa0db |
Refactor writable part (the _write and _writev functions) in net.Socket and http2.Http2Stream classes. Also involves adding a generic "WriteGeneric" method to the Http2Stream class based on net.Socket._writeGeneric, but behind a symbol. PR-URL: #20643 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Refactor writable part (the _write and _writev functions) in net.Socket and http2.Http2Stream classes. Also involves adding a generic "WriteGeneric" method to the Http2Stream class based on net.Socket._writeGeneric, but behind a symbol. PR-URL: #20643 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Refactor writable part (the _write and _writev functions) in net.Socket and http2.Http2Stream classes. Also involves adding a generic "WriteGeneric" method to the Http2Stream class based on net.Socket._writeGeneric, but behind a symbol. PR-URL: nodejs#20643 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Refactor writable part (the _write and _writev functions) in net.Socket and http2.Http2Stream classes. Also involves adding a generic "WriteGeneric" method to the Http2Stream class based on net.Socket._writeGeneric, but behind a symbol. PR-URL: nodejs#20643 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Refactor writable part (the _write and _writev functions) in net.Socket and http2.Http2Stream classes. Also involves adding a generic "WriteGeneric" method to the Http2Stream class based on net.Socket._writeGeneric, but behind a symbol. PR-URL: nodejs#20643 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Refactor writable part (the _write and _writev functions) in net.Socket and http2.Http2Stream classes. Also involves adding a generic "WriteGeneric" method to the Http2Stream class based on net.Socket._writeGeneric, but behind a symbol. Backport-PR-URL: #22850 PR-URL: #20643 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesRoadmap
http2.Http2Stream._writeandhttp2.Http2Stream._writevhttp2.Http2Stream._writeGenericnet.Socket._writeGenericandhttp2.Http2Stream._writeGenericwriteGenericfrominternal/stream_base_commons./cc @addaleax @nodejs/http2 @nodejs/net