From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server-vie001.gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_DBL_BLOCKED_OPENDNS, URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1751050322; bh=yS8bczP52lpL0Or8AV0Mgl85YlaJoYYYkVOFHW7b1TU=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:References: Resent-Date:Resent-From:Resent-To:Resent-Cc:User-Agent: Content-Type:Content-Transfer-Encoding; b=JuR2lC3j/Uaj0RSIdNdBorcNzXxF6My6fmUHiFzLy1Hp+RZzaGoLFEXD2DFvInEzC Z9uZlax/kT9LtQF+4+rxShbHkt+l3rNUIJDy6okzzHD3hlbJOMFB9A6YEcP2kyKheL 6RCqVjaiCnXVMOXsn9WK8Xz3RSJW0G3dHMG9KXz4/M0Fvclmf94sILeV6VoGiIRlaG lr0z0P+AF6+wKzFZ88vtT56JySEE/DwTog9PwgVcs/mbm3RR9r8LJpQGGYvZeaowPy rNHHQ77H7ILOWLmUuDWfD/qtGMSmSOeEGjNQ8HtLYtKO+cRp9WjS7kxnLEkqefHRmN YirIaG6mxALRA== Received: from biznet-home.integral.gnuweeb.org (unknown [182.253.126.214]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id A8B8E2109A2B; Fri, 27 Jun 2025 18:52:01 +0000 (UTC) Date: Sat, 28 Jun 2025 01:51:58 +0700 From: Ammar Faizi To: Alviro Iskandar Setiawan Cc: Yonle , GNU/Weeb Mailing List Subject: [GIT PULL] Implement getaddrinfo_a() for higher concurrency Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Bpl: hUx9VaHkTWcLO7S8CQCslj6OzqBx2hfLChRz45nPESx5VSB/xuJQVOKOB1zSXE3yc9ntP27bV1M1 List-Id: 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