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] Implement getaddrinfo_a() for higher concurrency
Date: Sat, 28 Jun 2025 01:51:58 +0700 [thread overview]
Message-ID: <aF7oTgEt+Q+DCCip@biznet-home.integral.gnuweeb.org> (raw)
Hi Alviro,
Based on our discussion on Telegram, this pull request introduces
the usage of `gaiaddrinfo_a()` to enhance the concurrency of DNS
resolution.
There are two main changes in this pull request:
- Use `gaiaddrinfo_a()` to achieve more concurrency.
Allow DNS resolver threads to perform multiple DNS queries
at once using gaiaddrinfo_a().
- And then, avoid `gaiaddrinfo_a()` if resolver threads are not exhausted.
The asynchronous `gaiaddrinfo_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 `gaiaddrinfo_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-2025-06-28
for you to fetch changes up to ae6691db8c9a5ec07de75cdda23d939794cce91e:
Avoid `gaiaddrinfo_a()` if resolver threads are not exhausted (2025-06-28 01:44:15 +0700)
----------------------------------------------------------------
gai_async-2025-06-28
----------------------------------------------------------------
Ammar Faizi (2):
Use `gaiaddrinfo_a()` to achieve more concurrency
Avoid `gaiaddrinfo_a()` if resolver threads are not exhausted
gwproxy.c | 241 ++++++++++++++++++++++++++++++++++------
1 file changed, 207 insertions(+), 34 deletions(-)
--
Ammar Faizi
next reply other threads:[~2025-06-27 18:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 18:51 Ammar Faizi [this message]
2025-06-27 18:58 ` [GIT PULL] Implement getaddrinfo_a() for higher concurrency Alviro Iskandar Setiawan
2025-06-27 18:59 ` Ammar Faizi
2025-06-27 19:07 ` [GIT PULL v2] " Ammar Faizi
2025-06-27 19:13 ` 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=aF7oTgEt+Q+DCCip@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