From patchwork Wed Jun 4 20:42:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 894009 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:430c:b0:3a4:ee3f:8f15 with SMTP id eq12csp23933wrb; Wed, 4 Jun 2025 13:44:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLeV8p532xP+/Nr/tHX5C2CVwU2hExMNQOEwjqQD5naImE70ZoFFlLKrNdQGK4ufJBhYl5Zg==@linaro.org X-Google-Smtp-Source: AGHT+IGogQiWP28cLR1EiubOvHZbZfif7sqLXm5i61OmeJkweGP3PDvjmJRWdxQrYKK+E5e9iDqZ X-Received: by 2002:a05:6214:dce:b0:6fa:ccff:352a with SMTP id 6a1803df08f44-6faf7042690mr76328166d6.37.1749069845493; Wed, 04 Jun 2025 13:44:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1749069845; cv=pass; d=google.com; s=arc-20240605; b=aFIGNITSV1k7owQ0Mr/VYrfEKx0egVZbNbfiZD6y1td/NhdQEglVJZCos+Cq0Yne15 xzzb0XSQAm6LL1mEPoUf8hrT9NV7lzqmVj/W8YFDW9E1ePsK2QO9VG/ObHoetIiKwlOV muFdwtDLjxZAr3Xngw5YPnJXPXnwgS/+rlI3OWOtwqkQaMJUl2pa/UvBmBlMjVdTRtfZ 3N2hR7CDwflCvYD3DrXxVr9OgVpCFt7t2QnGqA571b4ZfNbcL0bHxhUFx7i+Wr6Yk4Yi Fkkp8L/uxg+REKe2lh1Nl71v3j6hn4PXEPSx7p/ZxNW+Qn5mSh63IjHER0RvzPPARYDc gzaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter:arc-filter:dmarc-filter:delivered-to:dkim-filter; bh=FzRzPYNX6A/Yn4chIRhg/fqOcslWqDGLdChPlr07jjo=; fh=15rxvXN7K0X9p6jPVVxe1y5/53BpC+bqjxiOTDwET+E=; b=fqIqghrPn+4Ampmu3lGuBTom1npUDpYe77Eif7lFL1E42arAyy6INJBh9QJlm/dk0L e1OsojNLGCySp3zapexKth+8lE6Pb7iv8vUr5KFs1TZzMJPymsLXvHnjfXNOTAlyxAO7 Lxr12WeYS/S4/RlAVNbLol3BqhRh+/flDSIn9QHU/PTX6iIjNKZhfF+crqyWVNwVgyTS OMLx/rPJPFPRu6Z3n7mhFRPOvKSLs8+3ApR79xz17tv6otjIT1SAo4VHlw2bKN4v6sNo GmWf/fbOcGuxiFfeBIyMeWDUCy9JoPEJuZ3phmpzhR7/od4F1uo252YkX6J1nSmE4onu C75Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YnYRlj/o"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 6a1803df08f44-6fac6e59f55si153276576d6.210.2025.06.04.13.44.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jun 2025 13:44:05 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YnYRlj/o"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1682B3857BB0 for ; Wed, 4 Jun 2025 20:44:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1682B3857BB0 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=YnYRlj/o X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ua1-x933.google.com (mail-ua1-x933.google.com [IPv6:2607:f8b0:4864:20::933]) by sourceware.org (Postfix) with ESMTPS id C0E96385772F for ; Wed, 4 Jun 2025 20:43:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C0E96385772F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C0E96385772F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::933 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749069818; cv=none; b=jZAp7VtqN+GshGSyceClnLQjbicUR8wClF3X4kKud4QeTKQik2cLjscP43UoKScx1Cdy3XkjhBeaVhYu5XzDrDT6jsko6WD/U29EclR/5uuFe2oKrShJIc7RMrQ716uzxD5pe7rHhjhogLseqmfSH72RFAzis82iRXvn7KIY/SA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749069818; c=relaxed/simple; bh=qvbGVHrdyIalmPrJCKa6IxxI7px+pHsTYzZTAUVU984=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=t5Q+Jb1db7ZMTXHW8gDo2Hu+cD3LNd7SlIjDmzLSXD5CKyTTztAWc4+6DwkYvQ5QUxB9jf54hI2FNTk9kW1jS67g+/yBOy8oDqFOesd6fQHhsI9tgQihxfp9i4pi4MxtTRhB/amPMvHC/bQ4q7QD7UXP83ZK2pJEiV7yDggkS80= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C0E96385772F Received: by mail-ua1-x933.google.com with SMTP id a1e0cc1a2514c-87dfe906a87so115680241.0 for ; Wed, 04 Jun 2025 13:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749069817; x=1749674617; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FzRzPYNX6A/Yn4chIRhg/fqOcslWqDGLdChPlr07jjo=; b=YnYRlj/o9r3w4DPd8LCNqkNL8Kvalz+PZiiAHwSGuLP7pPCUiF4n1B43tF10iGaStc LYmX6tupGxdo+kQzM8VIKExwRPTDdCyAmU3K7x3PQ3BPLEIAji+QVeLMEvGqtrFRDopG AG4bK6eY8FeSTqrNmmPWW/48jDbt3nzed2R70NqylASRTvU6SBsPyxE9hw+RriOGHGyn 2GR/vahMmpxeAeXAxlaAeWzKSHAav7gZGSIkEoMb4zcD0YjxdzBuCOg+zaSuzGf9sw/r hb3QuVDO3P3FiNIVbzumsORm9Uw9Opu21qM1z/zLguS6vNRxAwfu3dRy3ajiRwLN4A1z KYow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749069817; x=1749674617; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FzRzPYNX6A/Yn4chIRhg/fqOcslWqDGLdChPlr07jjo=; b=FB6CzQdKJjpoJte4l8QSF5TR3fEDe4OnloEQ0Q/bc5f7Tzfch3JPVdoiEoJRCAQJqV XJwFdbqyWK7RdYmYmWZV0k9gXNce5laUjdkFqRE4at0pWdkVBibDg9qbw1TTq3dPkBQM yvVUGErpc+nwZVPqXpnc/2iIacTP26NABCilcf4tcy6QuxSKtIaXmTF1S1tCeQEujekk tIT0DrJVXnmrgWEYWBJKorVXICeIouW6WoEgbxR/So1pU5fVKZx6qjgV6iXy38WfBJLp Sto9ULmI1+c0tdoFchqXx6jqwX3SvM7SZQrGjZXRHIpxEO7666XKCFJfg1Ww6wwE6UDV D0Qg== X-Gm-Message-State: AOJu0YzSMpGVzIwFlpXHcMRP02wfULov6pFASYFthAka4P0o9Vy2L9bQ OodfqUyXyl9bS6lpe+9Ddj+yGbOFio/6TX7167SlWm6aKt+unCQkNu6EjRe/7SIcLEpch3qMtNd op0l+ X-Gm-Gg: ASbGnct7aj97n0azxcJTjKfKXOo79u6Q0ZlSblbImze5ZN9ihtTPpryNKlGY3KtTssa I7z79jk11+0jvpBudEl4ud5sCBfS/jEf98UKO2NrAJU0XLY9U5Cz7FDGUl4vof7Cr3B9GwU9IFZ ca7EIRegH7gt3JyVngYNWSK/t0G5sJ4xuXGt0/CfQgWWno3SNefo30dq33X215q/8NzgVkN4rOp aZKD11rQw8wSv/pIN9liWopx4BPOvEFKWOoPZHNKzu5oM3vS0KfpelIdFspoFCh6gT605P55cNl pYljTRJnAZUK9kGvS7KcKmd5SoBMaOBzzBI2EdixuGtH+RI/sy5vFVqAvNlfO9bx X-Received: by 2002:a05:6102:5ccc:b0:4e7:3efd:ac76 with SMTP id ada2fe7eead31-4e746cff8a9mr4343855137.8.1749069816904; Wed, 04 Jun 2025 13:43:36 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:8c5f:1160:8942:85f9:1203]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-87eaac49cdesm1020317241.2.2025.06.04.13.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jun 2025 13:43:36 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Collin Funk , Paul Eggert , Florian Weimer Subject: [PATCH v2 0/5] Optimize inet_ntop Date: Wed, 4 Jun 2025 17:42:39 -0300 Message-ID: <20250604204332.2090912-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org Some projects override inet_ntop because the glibc implementation shows a significant amount of overhead [1][2]. The main culprit is the internal sprintf, which requires a lot of internal function calls and is quite slow. The recent fortifying work required extra maintenance from these projects (and worse, it might prevent us from actually using the fortification depending on how the wrapper is implemented). To avoid the need to resort to such hacks, this patchset optimizes inet_ntop. The resulting performance should be similar to the one from frr project (and hopefully they might stop it to use a different implementation). Changes from v1: - Fixed bench-build with BENCHSET set to bench-resolv. - Optimized put_uint8. - Optimized inet_ntop6. - Implemented inet_ntoa on top of inet_ntop. Adhemerval Zanella (5): benchtests: Add IPv4 inet_ntop benchmark benchtests: Add IPv6 inet_ntop benchmark resolve: Proper indent resolv/inet_ntop.c resolv: Optimize inet_ntop inet: Implement inet_ntoa on top of inet_ntop benchtests/Makefile | 7 + benchtests/inet_ntop_ipv4-inputs | 1003 ++++++++++++++++++++++++++++ benchtests/inet_ntop_ipv4-source.c | 10 + benchtests/inet_ntop_ipv6-inputs | 1003 ++++++++++++++++++++++++++++ benchtests/inet_ntop_ipv6-source.c | 10 + inet/inet_ntoa.c | 7 +- resolv/inet_ntop.c | 364 +++++----- 7 files changed, 2229 insertions(+), 175 deletions(-) create mode 100644 benchtests/inet_ntop_ipv4-inputs create mode 100644 benchtests/inet_ntop_ipv4-source.c create mode 100644 benchtests/inet_ntop_ipv6-inputs create mode 100644 benchtests/inet_ntop_ipv6-source.c