From patchwork Tue Jun 3 19:51:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 893871 Delivered-To: patch@linaro.org Received: by 2002:adf:a2d4:0:b0:3a4:ee3f:8f15 with SMTP id t20csp486879wra; Tue, 3 Jun 2025 12:54:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXcbDyUkNQgewAGWATrh55GBmZDC4e3iuwwCA68dZTBqdrde6y7VlmXV8jaspnqRvVRDoRZfw==@linaro.org X-Google-Smtp-Source: AGHT+IGeHRAcqYue0QJSaciAuJ2mlPwVW5wWl74nLBQZ+X9sEF6Kw/hJZzg1gfgq9M73ZkiyLSPI X-Received: by 2002:a05:620a:c43:b0:7c5:5cd6:5cf2 with SMTP id af79cd13be357-7d219842703mr63250585a.17.1748980450441; Tue, 03 Jun 2025 12:54:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1748980450; cv=pass; d=google.com; s=arc-20240605; b=Id4Z1yZyNbyK78raKXXdlIBmbKV2JYiJBw8B8GDfqRzXsv+mTx1VhtTdmiCCtjqx8y kW/n50zRjB9P9Of8g+Zqhfqp3pZp+AzLmmGvNR2ZcIGl3ARA+5p2h0xamHr5LxuZpwFW M7FoXyWRt/cNlg+K34XAY4UitNx/D2AFEPgTwHXpBy6uPpECAFZY7hyEuMmjhoDItGT1 zZwgqOhQWGVyseUE3hWd38suUPb1EOOl+saTfyw9GeWBfeGnZDUdiDZ8op69I97/Pnpo gbbYVa2e+HnSEedFEH1aNZrq289tdliFieCJZvWRo78Qa1KWhOzd9g4g73LlIkbdqGRe yK8Q== 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=1KuhGfladoboBvsR+Qbaiex2Qt0n8D/cZaO+zCbMK5g=; fh=7/RTOikOdpDhr80qQ1MnirR4MhHwp+iZ0OKvKkXmJzI=; b=kM5MvjoNEEbLdSIS0jS5dmBugU61WD0F3sQPtnsIYQFWkkWKGD0sEBbQFsss+HhkJ6 m4NStSzcbVcVLb938LZlqDy0AZMHSqiTWNsUhXvYNqH/ZBZELG5SC3DcMTtAMKQTGS/O qcomiiO35mKGcnTIthGjJ74W3/MQ+7Rmdz6kp6pZjT2wOwxEtX9HEai5zCyt3bkaszQc zGqWSQ96eA6xAcj7qA8m1KFIlF/iZmEt1zUvHzI4Zo/2eUYMqMEaqBR0n9S0LTAaNGZU +6X7ISc9kTwdMcvuUwcBBh9XTm0n2hPhFVaUAsbTtXD/nOSpDwpkXpwp7C7Yv8vYFxuA H+/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qgBOpHR9; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 6a1803df08f44-6fac6dac7c2si129736976d6.40.2025.06.03.12.54.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jun 2025 12:54:10 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qgBOpHR9; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 ABD7F3858401 for ; Tue, 3 Jun 2025 19:54:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABD7F3858401 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=qgBOpHR9 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-vk1-xa33.google.com (mail-vk1-xa33.google.com [IPv6:2607:f8b0:4864:20::a33]) by sourceware.org (Postfix) with ESMTPS id 773B53858D34 for ; Tue, 3 Jun 2025 19:53:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 773B53858D34 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 773B53858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::a33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748980418; cv=none; b=lTCSxCmyHJl+q6S9nH4cEXeh3TPZmMCBabX+zve0O5fzbLxkcHNRVLxAmTokAvaMbNinM/V8VLQgHmIYyzgcGcxXsmdVJbptgZIGhxxujTDMNSNuVfqZ4eEdxh0BonSdHcpmhS5qYyamj0SXYxiCsawu1CBc8zYeQD5f/VCOWYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748980418; c=relaxed/simple; bh=dQNBkqlKl/VpvKyQonbJLbL+5/l9P7u984YLHxvm/DE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=b6tClQZdfH+cmcyBm3R0RHcIDJaGnXZ+RrCjcQgNTDyZ9aUOWllrTM0hQqFMgWRSTd0s7HC3aIw0sKEuoIB8EnuckiL2P6gxLbJDU8jNOehbAEXT4yTImnlA7UoAjszwXz0S86IdkwaT/ACOpAPiR9uzErCJiNvvfmx6GnWk0oQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 773B53858D34 Received: by mail-vk1-xa33.google.com with SMTP id 71dfb90a1353d-52934f4fb23so4002428e0c.1 for ; Tue, 03 Jun 2025 12:53:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1748980417; x=1749585217; 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=1KuhGfladoboBvsR+Qbaiex2Qt0n8D/cZaO+zCbMK5g=; b=qgBOpHR9REmI5MapSUX3q8JcXfTrc+8MQqPhKv6YwvlWtWIziO9ARWSUkkSreiZivh EC20aCtgaVzW4lbPyaSAWTqzLKoOSfQv+CXw81+IqOYkVlwGrnbdWMFdEQdpe+Ky+iaK sh/1nSSba0nemScjUOgke3mGmTlmIL6px5QHpLXIMG00nq8yHQBc7XGsJU92bFyoHWxj hRYXKx0C6/do8x/Z4ZCadL+LbGCo0dtPYgsif42uH2nGqcYJzDz3f6AxWtJCCw+DnsFH 2O73aLd+0olDw8UsTz+27fIIKvy22a2lGnWiU1NsJ3B9kf4tTcRxvMsVw3Lwi+uw+t/O Td7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748980417; x=1749585217; 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=1KuhGfladoboBvsR+Qbaiex2Qt0n8D/cZaO+zCbMK5g=; b=LYkznxOqRV5z96PQZ2RYZDsdVBYoG6uqb+o4eFAz3KbuZDtpgXQnAUjcLXK1edHw3c gzB+GZ39K+w5Zwa2BZzsfqawUDSocsvtJk3DiPGIRXdTmYoDv7RaKz4LxFK0ZwjgxdFs DBlOn9fGYnMaCNsbDOpN7h/ZwI+RIFTTH447EHSZPRX3hJAoLCFECBbpZWpQbuxFAMDJ s6gQ/ZXqKqIZR86zL5fjSXMFwi3XKlwabqHL9hTVgJP/Ox9ozh13M5nBtQO75KO3QQbo eSUI7KZgwcZvNznY5SSA3oK+AaL2oqAIim90iIJ61MKoa8xjtM0k9J9ypN6SL8z3yt+q 2DpA== X-Gm-Message-State: AOJu0YywIGraZp9125Mo0S8Pf5PmCuiIHQmMylWTVT9qG3KDjPHWlbPY Zy9oP19IGd/dcgIfN+eTWJYBHs2XSgUIcUjLBpHOE/bQm4gPHWCl1WOh2GtXByzA0X+AN7bBOj8 aaIHN X-Gm-Gg: ASbGncucOI08MdwZl6M/jDBqFj6sgNzpvSKCkOBMPQY8ifyh1TDuZWo6CbdEyBny8qc uB+AObQOa9nh4ZpyuBifI50dtQe4rGMySBp7Vnp4nInLQVtPFTuMWULQlp3wKgTHQZeM4ocayH7 VzbsOOlCzT15+G7KOU4DA1TJ5kuM9R9EaBGsi3ag4kJHc8jgDhTQBb2lNrnzdK7/bZLIMDEY9yi uCSZVpEJdTvVCKTJ5WAEFAaNpaBk9cvCdfNCZdmmA3BzYQ23rcbgtmtAv+5wgXC6QY0ish6uRS8 /wEOMZJ/pjLGh8K5Vlmnc94A5XGM2Tkp7tMuzB/zEEzvHgKi2svOgiGlmBeO/A+Z X-Received: by 2002:a05:6122:338a:b0:530:677b:1e81 with SMTP id 71dfb90a1353d-530c7076a80mr396954e0c.0.1748980417455; Tue, 03 Jun 2025 12:53:37 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:8c5f:3b12:b58a:98b8:5b2f]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-53074aaf498sm9857566e0c.5.2025.06.03.12.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jun 2025 12:53:36 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Carlos O'Donell , Andrew Pinski Subject: [PATCH 0/3] Optimize inet_ntop Date: Tue, 3 Jun 2025 16:51:51 -0300 Message-ID: <20250603195332.2822499-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). Adhemerval Zanella (3): benchtests: Add IPv4 inet_ntop benchmark benchtests: Add IPv6 inet_ntop benchmark resolv: Optimize inet_ntop benchtests/Makefile | 6 + 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 + resolv/inet_ntop.c | 134 ++-- 6 files changed, 2119 insertions(+), 47 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