Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x63hB-000S0f-10 for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Sep 2026 10:13:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x63hB-00CFt3-01 for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Sep 2026 10:13:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x63hA-00CFsm-25 for pgsql-hackers@lists.postgresql.org; Mon, 14 Sep 2026 10:13:52 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x63h6-00000000MgH-46Jf for pgsql-hackers@postgresql.org; Mon, 14 Sep 2026 10:13:52 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-c29667ed561so376403966b.2 for ; Mon, 14 Sep 2026 03:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=planetscale.com; s=google; t=1789380827; x=1789985627; darn=postgresql.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=p1AYzdOzh+E4KLwALL4z4/9mOn/SROsTXHGCcFCWdrU=; b=dWRZJGDd/PI0G9YDsAsyxS3Bvziu0pU8QoOufl3JL+T7AHvULDHE/DcS5slxjUnHMU 3IjQLDzrld4A3LhhVamnQrFUgbpX1a7TmzysO4topD0j+zF5s6BujpdbFwJqIsdDqIik dFB8qN+u6raZB3bSdWhFscfZebqFOLQni+x0LaLNCMsvNJxxL17OY66CdnDDOmWphNXV uiIsNcS79FMcHvFE+3S4tF+J5if2XX6KI2Lk/rsiJvQ3R5WWxvgAmDP3whGtBmgVGgkM 0O5sxfmE8R1C0bF+bn1C8XrXTaB0d5HGyHSjSE/rKVDaZRpecJNHF1vUlXVGZ3eqqEng bQvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789380827; x=1789985627; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=p1AYzdOzh+E4KLwALL4z4/9mOn/SROsTXHGCcFCWdrU=; b=A24Mlck6ZbM+joNPQaCA7KQznhE8lxUd0n5ue5IEGKHU+BxQKB6K7EM5gKTuTCkX+o dSx6vE6nGP/HeHkKdONAvv5MgcKoE8zFTJrtbqmcSQdsfgIYPi61zUERGLWLUJriaEVm euzaJwY5BYych7YGIbj5H1wSWmRLv6gTIQgDrPoIw6a20/LOHnK5Dk6pQp4JTxA++Jzw Wmq0Q+wIaAUYpfVhUfzXI5lMGCibjCNF4aQllmovriTS9syMBjzAK8qKqEwchqBP1xGO AyR2XmHXO2HWlLnJcMMqaVVRAYNfABVYaM5Ru+Ce6AOaptb690RtsRp1+ciiGqK8sHUC aSlQ== X-Forwarded-Encrypted: i=1; AKwUvBzuLB8jyAm5vWJ4/beG6O5hxFMPipTtEG/qoX/SCnDPeMjviuryl3vopAdS1VDuJgvB6g2tEWESQCfkPRFX@postgresql.org X-Gm-Message-State: AFuF++mdJNC93WCT6SWERXezNBBadGqiwLa/mZKbmKP9ud7cuV9Ku2tu ulsolxazZGfGIJBQiFosZMgyaETq47Q1FGDqFAH6hekn0+XbZdtuno5xz/KDxfzWYg8= X-Gm-Gg: AYBFou1fgr4nXuhOcfyMxklnVzWh8FAmyg+kdNnbnPfcPgCH5zyfZyEu/D4gN1Yyu/R ZSSGN8p8WMHrqkawxN2/yZIZnwN2MPofsobvaVokFrof7Z7yG6r7k2tbPKE/aXhrm96+964oswr DlKcH3d0PIx7HrDarG/p4eaSPMMbHp5A39whWXLiARFhul7aXwh/dJFCfg1e4sBHDD7IkKOvpKe XsCbpkroqmYjH1SD+x+HUFEVFtI7fNJkQzZBhkwvtNs2zuSVOuRCo0vMAfNJcwk7FyHlCdz7jm7 atzadqKBxMXLtmo3sICSDYaKOLbwiiDCYfXGa0MjgZrFlj6eBRZmEiZg411EUwAui3B/v8t+yc9 Nuo68hEM363cRWJLnGJwoVGjVmHnjIxJuOWUjB6W/WFEl6q9mRAqqNW2Grp8zOufVwz+lgxPE5S a9EEK4JLKPD41bTdzB/F6xfJAflzPdu868RzSNU+lWxnirpyJtFDLsU846aWbdFidh14iaRbzth pQgpT30/78Vt5Gv1LJ29eMMHbAeoilo86MbJS+ZsJ9BOXEuei2WC9UCG0HFOstEq/v1 X-Received: by 2002:a17:907:1c92:b0:c1f:e9d9:64d4 with SMTP id a640c23a62f3a-c29b862f42cmr112654066b.11.1789380827288; Mon, 14 Sep 2026 03:13:47 -0700 (PDT) Received: from ?IPV6:2a04:4540:6547:6400:4ddb:f1f9:299:89fe? ([2a04:4540:6547:6400:4ddb:f1f9:299:89fe]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c296601f4ccsm398009166b.20.2026.09.14.03.13.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Sep 2026 03:13:46 -0700 (PDT) Message-ID: <01612e7c-ac8c-45ad-9739-c13675cfd3e5@planetscale.com> Date: Mon, 14 Sep 2026 12:13:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Speed up repeat() for larger counts To: ChenhuiMo , pgsql-hackers Cc: Jeevan Chalke , Heikki Linnakangas References: <710c312b-2caf-4526-8950-8e0e504be2c1@planetscale.com> <1fe7eff1-b402-48b0-a1d1-48e5e79f8df7@planetscale.com> Content-Language: en-GB From: Jan Nidzwetzki In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Chenhui, Thanks for the new version and for splitting the patch set. It applies to the current master branch, and check-world passes. On 12.09.26 15:12, ChenhuiMo wrote: [...] > Here the non-temporal threshold is 12.625 MiB, so the first tested cap > at or above it is 16 MiB. This also matches the earlier measurements, > where cap16m was often the best choice for the larger-output cases. > > So the glibc non-temporal threshold appears to correlate well with the > preferred cap on both of my x86 systems. That settles it for me. Collecting the three x86 systems measured so far: system non-temporal threshold first cap at or above it J5005 1 MiB cap1m i5-13500H 1.3125 MiB cap2m i9-12900H 12.625 MiB cap16m In every case, the preferred cap is the first one at or above the threshold. So the 64 KB to 16 MB spread we started with is a glibc setting with three different values, not a hardware property. Review ====== In patch 2, CHECK_FOR_INTERRUPTS() is called after memset(). Usually, CHECK_FOR_INTERRUPTS() is called periodically to check whether a long-running task has to be aborted. After memset() returns, the actual heavy work is already done. Not sure if we actually need the check. In addition, I recommend a short comment for the new 'if (slen == 1)' path that describes that memset() is faster than the loop below. strings.sql offers only partial test coverage for the added conditions. I recommend adding at least these three tests to the existing ones to test the early return and the memset() fast path: SELECT repeat('', 10); SELECT repeat('x', 0); SELECT repeat('x', 4); Additional comments =================== Your new patch set has a different author than the previous ones. Please double-check that it contains the actual name you want visible in the commit. When you generate a new patch set, it is common to version it to make it easier for others to understand which version is most recent. You can do this by specifying the "-v" option when exporting the patch. For example, "git format-patch -v3 -2" generates version 3 of the patch series consisting of the last two commits. Best regards Jan -- Jan Nidzwetzki PlanetScale Postgres Core Team