public inbox for gwml@vger.gnuweeb.org
 help / color / mirror / Atom feed
* [GIT PULL] Implement getaddrinfo_a() for higher concurrency
@ 2025-06-27 18:51 Ammar Faizi
  2025-06-27 18:58 ` Alviro Iskandar Setiawan
  0 siblings, 1 reply; 5+ messages in thread
From: Ammar Faizi @ 2025-06-27 18:51 UTC (permalink / raw)
  To: Alviro Iskandar Setiawan; +Cc: Yonle, GNU/Weeb Mailing List

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-06-27 19:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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     ` [GIT PULL v2] " Ammar Faizi
2025-06-27 19:13       ` Alviro Iskandar Setiawan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox