From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
To: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Cc: Yonle <yonle@gnuweeb.org>, GNU/Weeb Mailing List <gwml@vger.gnuweeb.org>
Subject: [GIT PULL v2] Implement getaddrinfo_a() for higher concurrency
Date: Sat, 28 Jun 2025 02:07:12 +0700 [thread overview]
Message-ID: <aF7r4IM6xT2jDbtI@biznet-home.integral.gnuweeb.org> (raw)
In-Reply-To: <aF7qEl0RrHF5pDNM@biznet-home.integral.gnuweeb.org>
Hi Alviro,
[ v2: Fix typos, s/gaiaddrinfo_a/getaddrinfo_a/g ]
Based on our discussion on Telegram, this pull request introduces
the usage of `getaddrinfo_a()` to enhance the concurrency of DNS
resolution.
There are two main changes in this pull request:
- Use `getaddrinfo_a()` to achieve more concurrency
Allow DNS resolver threads to perform multiple DNS queries
at once using getaddrinfo_a().
- And then, avoid `getaddrinfo_a()` if resolver threads are not exhausted.
The asynchronous `getaddrinfo_a()` function, while non-blocking,
comes with a hidden cost: it spawns a new thread for every
single query. This frequent creation and destruction of threads
is inefficient and can become a major bottleneck.
Check the number of active DNS queries against the pool of
available resolver threads. If there are idle threads ready to
work, we delegate new DNS lookups to them using the synchronous
`getaddrinfo()`. It reuses existing threads and completely
avoids the overhead of creating new ones.
The costly `getaddrinfo_a()` is now only used as a fallback when
the entire pool of resolver threads is exhausted. This leads to
a more robust, efficient, and scalable DNS resolution mechanism.
Please pull!
The following changes since commit 46147b0405ae7565f2b3bc12488bc51653ed5d67:
Delete fd from epoll early to avoid EPOLLIN being fired later (2025-06-27 21:39:08 +0700)
are available in the Git repository at:
https://github.com/ammarfaizi2/gwproxy tags/gai_async-v2-2025-06-28
for you to fetch changes up to 7a4ca1ebc41b421e44bf83ad23c8bd06c2ed0a17:
Avoid `getaddrinfo_a()` if resolver threads are not exhausted (2025-06-28 02:02:20 +0700)
----------------------------------------------------------------
gai_async-v2-2025-06-28
----------------------------------------------------------------
Ammar Faizi (2):
Use `getaddrinfo_a()` to achieve more concurrency
Avoid `getaddrinfo_a()` if resolver threads are not exhausted
gwproxy.c | 241 ++++++++++++++++++++++++++++++++++------
1 file changed, 207 insertions(+), 34 deletions(-)
--
Ammar Faizi
next prev parent reply other threads:[~2025-06-27 19:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 18:51 [GIT PULL] Implement getaddrinfo_a() for higher concurrency Ammar Faizi
2025-06-27 18:58 ` Alviro Iskandar Setiawan
2025-06-27 18:59 ` Ammar Faizi
2025-06-27 19:07 ` Ammar Faizi [this message]
2025-06-27 19:13 ` [GIT PULL v2] " Alviro Iskandar Setiawan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aF7r4IM6xT2jDbtI@biznet-home.integral.gnuweeb.org \
--to=ammarfaizi2@gnuweeb.org \
--cc=alviro.iskandar@gnuweeb.org \
--cc=gwml@vger.gnuweeb.org \
--cc=yonle@gnuweeb.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox