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_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=new2025; t=1757228777; bh=GZ2D4HjCIEoDr0x9b1DgwbjYPIRO0K/i1Oz259nPV9o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To:X-Gw-Outgoing-Server-Hash:X-Gw-Message-ID: X-Gw-PM-Hash: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=it7mCQOosHeGcuU705wJ82KD86U9QydWj2pe/Va6L2UtKF6gnhFVeKrFMPFrgnbOp oIuk/KxqaRzaOjJ/LOrI0wTHALROKYAcn58YUvS2vszKlwBR9ISnvepgFOoURCx55f va2KMIY+Tzie69KJDxzx04pc4rctZvCA/TsQQBOEi2cXhFe4uHI7iO1gPjBsWwhC6s sANK4xhLOWCbaApk9m+f5Sb2A3cVhna0fWVQ3UtJ6R+wU43C94RxZVkdzJux6KrNb1 k8HjS9vpOBoP81/m9NjtZFW2HlBoFBOk4IGEtNSPkfFao7YWjo/cWwv60a/IF3VniY jWaVuQwcFHKTg== Received: from linux.gnuweeb.org (unknown [182.253.126.215]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id D833F31279DD; Sun, 7 Sep 2025 07:06:16 +0000 (UTC) Date: Sun, 7 Sep 2025 14:06:13 +0700 From: Ammar Faizi To: Ahmad Gani Cc: Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: Re: [PATCH gwproxy v8 2/2] gwproxy: refactor code base to add experimental raw DNS backend Message-ID: <20250907070613.GC3438918-ammarfaizi2@gnuweeb.org> References: <20250829075557.598176-1-reyuki@gnuweeb.org> <20250829075557.598176-3-reyuki@gnuweeb.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Gw-Outgoing-Server-Hash: 01afd303c8b96d0c1d5e80aa96a4ee40ec69888f786fa24107c0862c0644af79 X-Gw-Message-ID: 690dd880985d0a42d2bdb5ddadf81cbcfe91a68532b02445cc56e3f6edcdc8cb X-Gw-PM-Hash: 520861c61013bf5416b1bc71a39e945deaa5e303b1c1161cdb62ce9c850bc926 List-Id: On Sun, Sep 07, 2025 at 01:39:05PM +0700, Ahmad Gani wrote: > I think 65536 is a pretty low memory footprint in modern systems; as Sir > Alviro noted, it's around 0.25 or 0.5 MB. > > Maybe it's more beneficial to allocate at once in the stack rather than > add instructions for growing/shrinking the allocated memory? Yes, it's small. But I prefer to save the space for it. The memory saving is very beneficial for a small Linux device like Raspberry Pi, 4G modems, or even your lovely home routers. Also, when you have 65536 clients in a single thread, that doesn't necessarily mean your DNS mapping are fully used from index 0 to 65535. A DNS query is a short-lived object. You only need to keep it until the DNS query receives a response. Having 65536 outstanding DNS queries is very unlikely even with 100K concurrent connections. Especially given the cache feature, you will skip the DNS resolution if identical names are accessed very often. I believe allocating it lazily is a good way for this design. If the initial size, 16, feels too low for you. You may consider adding an option to customize the initial size via CLI args. -- Ammar Faizi