GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||
GeezerVison is showing github.com — dns: coalesce identical concurrent lookup() requests by orgads · Pull Request #62599 · nodejs/node Conversation
Contributor
When multiple callers issue dns.lookup() for the same (hostname, family, hints, order) concurrently, only one getaddrinfo call is now dispatched to the libuv threadpool. All callers share the result. getaddrinfo is a blocking call that runs on the libuv threadpool (capped at 4 threads by default, with a slow I/O concurrency limit of 2). When DNS resolution is slow - e.g. ~10-20 s per call due to a misbehaving resolver - identical requests queue behind each other, causing timeouts that grow linearly with the number of concurrent callers: Before: 100 parallel lookup('host') -> 50 batches × 10 s = 500+ s This is particularly severe on WSL, where the DNS relay rewrites QNAMEs in responses (appending the search domain), causing glibc to discard them as non-matching and wait for a 5s timeout per retry. The coalescing is keyed on (hostname, family, hints, order) so lookups with different options still get separate getaddrinfo calls. Each caller independently post-processes the shared raw result (applying the 'all' flag, constructing address objects, etc.). Fixes: #62503
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
orgads
force-pushed
the
dns-coalesce-lookup
branch
from
36f0f63 to
c754d12
Compare
orgads
force-pushed
the
dns-coalesce-lookup
branch
from
c754d12 to
b213b0f
Compare
|
There was an error while loading. Please reload this page.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@ ## main #62599 +/- ## ========================================== - Coverage 92.96% 90.65% -2.31% ========================================== Files 428 797 +369 Lines 195232 278281 +83049 Branches 30184 53510 +23326 ========================================== + Hits 181492 252271 +70779 - Misses 13413 16384 +2971 - Partials 327 9626 +9299
🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think this might break async_hooks continuation, could you verify? Adding an AsyncResource on coalescing would be enough.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
b213b0f to
cee78bf
Compare
|
Great observation! Should be fixed now. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
cee78bf to
610a0c3
Compare
|
I have a feeling that the failing test on GHA is relevant, can you take a look? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
It doesn't look related. Similar failures happened here and here. Also, this test calls The test is flaky, since it relies on external systems which may refuse or time out. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
When multiple callers issue dns.lookup() for the same (hostname, family,
hints, order) concurrently, only one getaddrinfo call is now dispatched
to the libuv threadpool. All callers share the result.
getaddrinfo is a blocking call that runs on the libuv threadpool (capped
at 4 threads by default, with a slow I/O concurrency limit of 2). When
DNS resolution is slow - e.g. ~10-20 s per call due to a misbehaving
resolver - identical requests queue behind each other, causing timeouts
that grow linearly with the number of concurrent callers:
Before: 100 parallel lookup('host') -> 50 batches × 10 s = 500+ s
After: 100 parallel lookup('host') -> 1 getaddrinfo call = ~10 s
This is particularly severe on WSL, where the DNS relay rewrites QNAMEs
in responses (appending the search domain), causing glibc to discard
them as non-matching and wait for a 5s timeout per retry.
The coalescing is keyed on (hostname, family, hints, order) so lookups
with different options still get separate getaddrinfo calls. Each
caller independently post-processes the shared raw result (applying the
'all' flag, constructing address objects, etc.).
Signed-off-by: Orgad Shaneh <[email protected]>
PR-URL: nodejs#62599
Fixes: nodejs#62503
610a0c3 to
6572e6e
Compare
|
Rebased. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
ping? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
When multiple callers issue dns.lookup() for the same (hostname, family,
hints, order) concurrently, only one getaddrinfo call is now dispatched
to the libuv threadpool. All callers share the result.
getaddrinfo is a blocking call that runs on the libuv threadpool (capped
at 4 threads by default, with a slow I/O concurrency limit of 2). When
DNS resolution is slow - e.g. ~10-20 s per call due to a misbehaving
resolver - identical requests queue behind each other, causing timeouts
that grow linearly with the number of concurrent callers:
Before: 100 parallel lookup('host') -> 50 batches × 10 s = 500+ s
After: 100 parallel lookup('host') -> 1 getaddrinfo call = ~10 s
This is particularly severe on WSL, where the DNS relay rewrites QNAMEs
in responses (appending the search domain), causing glibc to discard
them as non-matching and wait for a 5s timeout per retry.
The coalescing is keyed on (hostname, family, hints, order) so lookups
with different options still get separate getaddrinfo calls. Each
caller independently post-processes the shared raw result (applying the
'all' flag, constructing address objects, etc.).
Signed-off-by: Orgad Shaneh <[email protected]>
PR-URL: nodejs#62599
Fixes: nodejs#62503
|
ping? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
When multiple callers issue dns.lookup() for the same (hostname, family,
hints, order) concurrently, only one getaddrinfo call is now dispatched
to the libuv threadpool. All callers share the result.
getaddrinfo is a blocking call that runs on the libuv threadpool (capped
at 4 threads by default, with a slow I/O concurrency limit of 2). When
DNS resolution is slow - e.g. ~10-20 s per call due to a misbehaving
resolver - identical requests queue behind each other, causing timeouts
that grow linearly with the number of concurrent callers:
Before: 100 parallel lookup('host') -> 50 batches × 10 s = 500+ s
After: 100 parallel lookup('host') -> 1 getaddrinfo call = ~10 s
This is particularly severe on WSL, where the DNS relay rewrites QNAMEs
in responses (appending the search domain), causing glibc to discard
them as non-matching and wait for a 5s timeout per retry.
The coalescing is keyed on (hostname, family, hints, order) so lookups
with different options still get separate getaddrinfo calls. Each
caller independently post-processes the shared raw result (applying the
'all' flag, constructing address objects, etc.).
Signed-off-by: Orgad Shaneh <[email protected]>
PR-URL: nodejs#62599
Fixes: nodejs#62503
7ea9614 to
6e7026d
Compare
|
Rebased |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Landed in ec4d4c2 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
When multiple callers issue dns.lookup() for the same (hostname, family,
hints, order) concurrently, only one getaddrinfo call is now dispatched
to the libuv threadpool. All callers share the result.
getaddrinfo is a blocking call that runs on the libuv threadpool (capped
at 4 threads by default, with a slow I/O concurrency limit of 2). When
DNS resolution is slow - e.g. ~10-20 s per call due to a misbehaving
resolver - identical requests queue behind each other, causing timeouts
that grow linearly with the number of concurrent callers:
Before: 100 parallel lookup('host') -> 50 batches × 10 s = 500+ s
After: 100 parallel lookup('host') -> 1 getaddrinfo call = ~10 s
This is particularly severe on WSL, where the DNS relay rewrites QNAMEs
in responses (appending the search domain), causing glibc to discard
them as non-matching and wait for a 5s timeout per retry.
The coalescing is keyed on (hostname, family, hints, order) so lookups
with different options still get separate getaddrinfo calls. Each
caller independently post-processes the shared raw result (applying the
'all' flag, constructing address objects, etc.).
Signed-off-by: Orgad Shaneh <[email protected]>
Fixes: #62503
PR-URL: #62599
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
Notable changes: child_process: * (SEMVER-MINOR) add subprocess.timedOut (Marco) #66639 crypto: * (SEMVER-MINOR) make X.509 inspection guards explicit (Filip Skokan) #67245 * (SEMVER-MINOR) add X.509 generation with CSR support (Filip Skokan) #67245 dns: * (SEMVER-MINOR) coalesce identical concurrent lookup() requests (Orgad Shaneh) #62599 doc: * add efekrskl to collaborators (Efe Karasakal) #67376 * add Philipp Dunkel to contributors (Philipp Dunkel) #67378 * add christianaurichzm to collaborators (Christian Aurich Zanettini Martins) #67377 http: * (SEMVER-MINOR) batch body spans per parser execute (Guilherme Araújo) #67187 sea: * (SEMVER-MINOR) generate a compile cache for the VFS modules (Matteo Collina) #66768 worker: * (SEMVER-MINOR) preload streams into startup snapshot (Matteo Collina) #66311 PR-URL: #67415
Notable changes: child_process: * (SEMVER-MINOR) add subprocess.timedOut (Marco) #66639 crypto: * (SEMVER-MINOR) make X.509 inspection guards explicit (Filip Skokan) #67245 * (SEMVER-MINOR) add X.509 generation with CSR support (Filip Skokan) #67245 dns: * (SEMVER-MINOR) coalesce identical concurrent lookup() requests (Orgad Shaneh) #62599 doc: * add efekrskl to collaborators (Efe Karasakal) #67376 * add Philipp Dunkel to contributors (Philipp Dunkel) #67378 * add christianaurichzm to collaborators (Christian Aurich Zanettini Martins) #67377 http: * (SEMVER-MINOR) batch body spans per parser execute (Guilherme Araújo) #67187 sea: * (SEMVER-MINOR) generate a compile cache for the VFS modules (Matteo Collina) #66768 worker: * (SEMVER-MINOR) preload streams into startup snapshot (Matteo Collina) #66311 PR-URL: #67415
|
Nice fix! We ran into exactly this on Node 22. DNS went down and the Any chance this gets backported to v26.x? Or even v22.x? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
When multiple callers issue dns.lookup() for the same (hostname, family,
hints, order) concurrently, only one getaddrinfo call is now dispatched
to the libuv threadpool. All callers share the result.
getaddrinfo is a blocking call that runs on the libuv threadpool (capped
at 4 threads by default, with a slow I/O concurrency limit of 2). When
DNS resolution is slow - e.g. ~10-20 s per call due to a misbehaving
resolver - identical requests queue behind each other, causing timeouts
that grow linearly with the number of concurrent callers:
Before: 100 parallel lookup('host') -> 50 batches × 10 s = 500+ s
After: 100 parallel lookup('host') -> 1 getaddrinfo call = ~10 s
This is particularly severe on WSL, where the DNS relay rewrites QNAMEs
in responses (appending the search domain), causing glibc to discard
them as non-matching and wait for a 5s timeout per retry.
The coalescing is keyed on (hostname, family, hints, order) so lookups
with different options still get separate getaddrinfo calls. Each
caller independently post-processes the shared raw result (applying the
'all' flag, constructing address objects, etc.).
Signed-off-by: Orgad Shaneh <[email protected]>
Fixes: nodejs#62503
PR-URL: nodejs#62599
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
Notable changes: child_process: * (SEMVER-MINOR) add subprocess.timedOut (Marco) nodejs#66639 crypto: * (SEMVER-MINOR) make X.509 inspection guards explicit (Filip Skokan) nodejs#67245 * (SEMVER-MINOR) add X.509 generation with CSR support (Filip Skokan) nodejs#67245 dns: * (SEMVER-MINOR) coalesce identical concurrent lookup() requests (Orgad Shaneh) nodejs#62599 doc: * add efekrskl to collaborators (Efe Karasakal) nodejs#67376 * add Philipp Dunkel to contributors (Philipp Dunkel) nodejs#67378 * add christianaurichzm to collaborators (Christian Aurich Zanettini Martins) nodejs#67377 http: * (SEMVER-MINOR) batch body spans per parser execute (Guilherme Araújo) nodejs#67187 sea: * (SEMVER-MINOR) generate a compile cache for the VFS modules (Matteo Collina) nodejs#66768 worker: * (SEMVER-MINOR) preload streams into startup snapshot (Matteo Collina) nodejs#66311 PR-URL: nodejs#67415
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
dns.lookup: pending promises grow unboundedly under sustained EAI_AGAIN load
There was an error while loading. Please reload this page.