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

import http request performance regression between 20.x and 22.x #57649

Open
perpil opened this issue Mar 27, 2025 · 1 comment
Open

import http request performance regression between 20.x and 22.x #57649

perpil opened this issue Mar 27, 2025 · 1 comment

Comments

@perpil
Copy link

perpil commented Mar 27, 2025

Version

20.19 and 22.14

Platform

`Darwin macbookpro.lan 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:16 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000 arm64`

Subsystem

http

What steps will reproduce the bug?

Run the following code in node 20.19 and node 22.14

import {request} from "http"
❯ time node import.mjs
node import.mjs  0.03s user 0.01s system 82% cpu 0.049 total
❯ node --version
v20.19.0
❯ time node import.mjs
node import.mjs  0.04s user 0.05s system 49% cpu 0.176 total
❯ node --version
v22.14.0

How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior? Why is that the expected behavior?

Node 22.14 uses similar CPU to Node 20.19

What do you see instead?

In Node 22, the same code loads the undici bits which requires a lot more CPU. Node 20 does not.

Image

Image

Additional information

I was investigating a performance regression in coldstart time between Node 20 and Node 22 in the AWS Lambda environment. Between Node 20 and Node 22, there is a +50 ms regression in coldstart performance when you instantiate clients using the AWS Javascript SDK V3. I was able to trace the issue to the clients always importing the node http request library regardless of whether the client used https only.

If you can make the loading of the undici bits lazier, I don't think they are actually needed until you start using the http request itself in certain scenarios and this will address the coldstart performance issue between node 20 and node 22 in the AWS Lambda environment.

@panva
Copy link
Member

panva commented Mar 27, 2025

Possibly related to #57581?

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

No branches or pull requests

2 participants