http: Eliminate ClientRequest capture by Agent socket listeners#10134
http: Eliminate ClientRequest capture by Agent socket listeners#10134evantorrie wants to merge 4 commits intonodejs:masterfrom
Conversation
lib/_http_agent.js
Outdated
There was a problem hiding this comment.
Can you do this without attaching to the prototype. In its current form, this will become unofficial API that we'll have to maintain.
There was a problem hiding this comment.
I changed it to just a file level function.
|
@cjihrig Changed per review |
lib/_http_agent.js
Outdated
There was a problem hiding this comment.
You should be able to replace self with agent now.
|
@cjihrig Changes made as requested. |
cjihrig
left a comment
There was a problem hiding this comment.
LGTM with one small nit. CI: https://ci.nodejs.org/job/node-test-pull-request/5309/
lib/_http_agent.js
Outdated
There was a problem hiding this comment.
Can you remove this blank line.
|
Removed the blank line. @cjihrig |
bnoordhuis
left a comment
There was a problem hiding this comment.
LGTM but can you make sure the commit log conforms to the style guide from CONTRIBUTING.md?
054d7b2 to
97f80b9
Compare
|
@bnoordhuis Does that look better? Do you want me to rebase/squash? Or is that something you do on your end? |
|
The only CI failure was the linter. Does |
Move the onFree/onClose/onRemote listeners to a separate function
Keepalive sockets that are returned to the agent's freesocket pool were previously capturing a reference to the ClientRequest that initiated the request. This commit eliminates that by moving the installation of the socket listeners to a different function.
|
@cjihrig Yes, works for me: |
97f80b9 to
518d33d
Compare
|
@cjihrig Is there anything more I need to do here? |
|
test/arm and test/smartos look like flaky failures unrelated to this change. |
evanlucas
left a comment
There was a problem hiding this comment.
LGTM. Running CI one more time to try and get a green build: https://ci.nodejs.org/job/node-test-pull-request/5418/
Thanks!
|
These CI failures still look unrelated to this change - are the particular failing tests known to be flaky? |
|
@evanlucas CI failure seems to be unrelated to this change. |
Keepalive sockets that are returned to the agent's freesocket pool were previously capturing a reference to the ClientRequest that initiated the request. This commit eliminates that by moving the installation of the socket listeners to a different function. PR-URL: #10134 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
|
Landed in c04d4df |
Keepalive sockets that are returned to the agent's freesocket pool were previously capturing a reference to the ClientRequest that initiated the request. This commit eliminates that by moving the installation of the socket listeners to a different function. PR-URL: nodejs#10134 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Keepalive sockets that are returned to the agent's freesocket pool were previously capturing a reference to the ClientRequest that initiated the request. This commit eliminates that by moving the installation of the socket listeners to a different function. PR-URL: nodejs#10134 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Keepalive sockets that are returned to the agent's freesocket pool were previously capturing a reference to the ClientRequest that initiated the request. This commit eliminates that by moving the installation of the socket listeners to a different function. PR-URL: nodejs#10134 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Keepalive sockets that are returned to the agent's freesocket pool were previously capturing a reference to the ClientRequest that initiated the request. This commit eliminates that by moving the installation of the socket listeners to a different function. PR-URL: nodejs#10134 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
|
This does not land cleanly in LTS. Added dont-land label. Please feel free to manually backport |
Keepalive sockets that are returned to the agent's freesocket pool were previously capturing a reference to the ClientRequest that initiated the request. This commit eliminates that by moving the installation of the socket listeners to a different function. Backport-PR-URL: #15500 PR-URL: #10134 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Keepalive sockets that are returned to the agent's freesocket pool were previously capturing a reference to the ClientRequest that initiated the request. This commit eliminates that by moving the installation of the socket listeners to a different function. Backport-PR-URL: #15500 PR-URL: #10134 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Checklist
make -j8 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
http
Description of change
Eliminate capture of createSocket callback in onFree/onClose/onRemote listeners by moving them to a separate function.
Fixes #10133
This reduces the heap usage by eliminating the capture in a prior context of the ClientRequest object associated with the first call that opens a socket. Let me know the best way to provide tests for this, as it's non-obvious to me how to do so.
I have provided a heapsnapshot screen shot in the accompanying issue (#10133), and will attach a similar heapsnapshot screen shot showing usage after this fix is included.
