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=1751051236; bh=m4y63AfaqYzkZMe0wFi8KhfTI9XgofHeSrbxCsP9c04=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To: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=tZLsccduDKSZMfvcpKDFDK/WASokte9DuNm2PrP/jvZCD++NjRNY3h2acIL2+ZOes zysR0jC4dAJ/1Qy5EojWtj+BYQbZKF+9nhxN2qTT2b/98ytvw63JyuIJF+JMlxF856 4I//Lh0K+pRCOPQ3T4aqDWDp6ZR6i7cJGozijy89iWr9zvyGDF8u/O1oaD0b49r3Th 0nhPgpNa8l7wnZ+Iryc/dTX3c8952mcxB/NdlxOiQcm6OLZO4yWVKCe3W0gvNGxmy1 9PMVgCj08xiapBMEAUTztjGBA6qyXHOAi/N++0siEgl8OtLFOmlMxHEY1j5w2pdbmP uK9tlWh5KYhfQ== Received: from biznet-home.integral.gnuweeb.org (unknown [182.253.126.214]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id F274121099E7; Fri, 27 Jun 2025 19:07:15 +0000 (UTC) Date: Sat, 28 Jun 2025 02:07:12 +0700 From: Ammar Faizi To: Alviro Iskandar Setiawan Cc: Yonle , GNU/Weeb Mailing List Subject: [GIT PULL v2] Implement getaddrinfo_a() for higher concurrency Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bpl: hUx9VaHkTWcLO7S8CQCslj6OzqBx2hfLChRz45nPESx5VSB/xuJQVOKOB1zSXE3yc9ntP27bV1M1 List-Id: 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