You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constdispatcher=newPool('http://127.0.0.1:8090'/* an 4worker nginx */,{pipelining: 30,connections: 100,});constproxy=http.createServer((req,res)=>{dispatcher.request({// the constructor of RequestHandler in undici/lib/api/api-request.jsmethod: req.method,path: req.url,headers: req.headers,body: req,},(err,{ statusCode, headers, body /** a Readable */})=>{if(err){throwerr}res.writeHead(statusCode,headers);pipe(body,res);});});functionpipe(src,dst){src.on('readable',()=>{letchunk;while(null!==(chunk=src.read(65536))){dst.write(chunk);}});src.on('end',()=>{dst.end()});}
Bug Description
parseHeaders in the utils.js seems too slow.
Reproducible By
Expected Behavior
Less CPU time spent in parseHeaders
Logs & Screenshots
Environment
Node 22
linux
Additional context
I open this issue because I've spotted some optimization for lowercasing the headers in node's built-in HTTP module, https://github.com/nodejs/node/blob/2e458d973638d01fcb6a0d7d611e0120a94f4d35/lib/_http_incoming.js#L279C3-L279C3
basically, it matches the known header field and use the cached string if found. Maybe we can adapt the same trick here to eliminate the
toString()
andtoLowercase()
overhead in parseHeaders.The text was updated successfully, but these errors were encountered: