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 1vQS3w-007pP2-2L for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Dec 2025 15:13:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQS3v-008XX8-1I for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Dec 2025 15:13:07 +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 1vQS3v-008XX0-0N for pgsql-hackers@lists.postgresql.org; Tue, 02 Dec 2025 15:13:07 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vQS3t-002ktH-0g for pgsql-hackers@postgresql.org; Tue, 02 Dec 2025 15:13:07 +0000 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-641977dc00fso8228275a12.1 for ; Tue, 02 Dec 2025 07:13:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764688384; x=1765293184; darn=postgresql.org; h=content-transfer-encoding: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; bh=lX2/disuCg6RQ7UOVQwEHnFO/ymwoSGVRZI+9U/zWxE=; b=QRJg5eQgInXsMitC+vY8Um/IL7KQ595hm8minjVUYI8eGZP/U1Blte7UvVkn5dqcUk T5psRnEuyOkltKD9kCmR1cYRVhtJi1gyAlIsrfcs69EB49PNcsYlfq7uZkIaYNehvIey 5G4qxz3cfApKiXEnmp/g5JmKuBvngJWnsjVsZnhd5u+YT2+iDCOh474pT/qMXCrF4Gtl /9iO0NYk9LLWsQ0N/wV5pa+xxmXhT0lnVne2uDhIbUaeSYskPFazD9UlHHGIHYtzoMxG qnpRO2NLhftyUTU2gRisLUhna8WIlp8UBTHMD4spWa8kHwfGKaeKOpp9PVVcKGYi9iq0 w+BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764688384; x=1765293184; h=content-transfer-encoding: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; bh=lX2/disuCg6RQ7UOVQwEHnFO/ymwoSGVRZI+9U/zWxE=; b=JgSAY+ZS0S4UEqnAOV43hJQ3SQV6wyVqtDbMpfcRCg9Cu2b0rIpqXHeAeu4lHnTtjO lpoGdDb+Q2Q+XJNUtvGGrlyIfvDKPF78Kqu6o5WWI7vUb6tObL5MW/zNdY9g5pmgB/zU OUxHLgD/f+TX6LRJC4kpydNQC/MgPUJLmgVRrfu77pLqVPLVAImUV7GOLlAkDlHWE9pu Ofm/uopbLZnHQG39dR95BTIdbzNDpg00d89xA45bZidA+xLR+5CystkvHEyLlLe8vIlD yyhDWNV1Mc2n85sj7/NTlVp2iN5IhSpYCuiJrrhjz2ys7rtXvOqSGorA7g29cepJMn+A KR9g== X-Forwarded-Encrypted: i=1; AJvYcCV9mK+Cw3MyXHCAhXsP9FqRMw8AvUu+fRPE+uEysQvXcDuZs0R2rT9nY7+iFi9otWLyv6cytE05vmJ6Xy/5@postgresql.org X-Gm-Message-State: AOJu0YxnghCiY57At/kdtCu08cM021uw4kxIJpERmBnFemV9gVlI4PGt QrBAkBGncd4IGPFb3saVzUfssJSZp3JMDby8MXIpccZBPCLJpQjzUcYhCgBOHw== X-Gm-Gg: ASbGncuD/PekaiK/PFIWDqz4gv1OZIC7cAP4VOfl3DX1svuerkRKTEp+O5+K+GiUwdC qn6Cg3zvC/wBzYDfoVWAj9ih2lNitrCT/3Q9gw8J1akjgGn+4DZasH1JvIoQRSy01wrOa1NkKP5 k4AN6mWCE4fEqJumzBsYXzQ9u9oRJFpmpZD7il9exs7UCtYFbEuEA5K6f3Oag/krp+G/NUHDr+M CBcK4/f2orSkaKB31UFUyDLOOixB4etiTNxK9kAM+DFxr6rDQxXaaCZtsOjUjRWRRstH4Bj38U6 BAYzrt1MXmFrGNDD3H+CeoKv7/4QyYjn+q++97JcD4usnHh/jCCrNQt9QkQQ7N4Sr6dTRCnvO3I ZUvaEgdSwLkOvrNPe6MzBgz6pAc3qk8bOF5dPYxYyw9kgkg6yGfhdOwo41quztI1i/meOxYyezM QIkUo8VTtPDZVAzcM= X-Google-Smtp-Source: AGHT+IFbdgrns6R/X66olQUW5CSbZ92u9Padyv1jLagh13vq0ccdi9ADOKMqW9XiggUdYxjIbscMLg== X-Received: by 2002:a05:6402:278e:b0:640:fa18:87be with SMTP id 4fb4d7f45d1cf-64554676560mr37346815a12.23.1764688383718; Tue, 02 Dec 2025 07:13:03 -0800 (PST) Received: from [192.168.2.32] ([165.225.27.7]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-64750a6ea41sm15696585a12.7.2025.12.02.07.13.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Dec 2025 07:13:03 -0800 (PST) Message-ID: <143d3184-b575-49bd-8bc1-f37f45f010cc@gmail.com> Date: Tue, 2 Dec 2025 16:13:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Consistently use palloc_object() and palloc_array() To: Thomas Munro Cc: Tom Lane , Chao Li , pgsql-hackers References: <524587.1764365323@sss.pgh.pa.us> <1e7f0c17-a965-4d5b-ad88-b435a4d97490@gmail.com> Content-Language: en-US From: David Geier In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 28.11.2025 23:31, Thomas Munro wrote: > On Sat, Nov 29, 2025 at 10:47 AM David Geier wrote: >> I intentionally tried to avoid any semantic changes but it's of course >> possible something slipped through by accident. > > Do you expect the generated code to be identical? Is it? In the majority of cases yes. However, there are a few cases where a small change in the C code can yield to differences in the generated code: I used the following bash script to create the disassembly of all object files in the build directory. I ran this script twice, once on master and once on the patched branch. The directory needs to be adapted accordingly in the script. find . -name "*.o" -print0 | while IFS= read -r -d '' file; do mkdir -p ~/Desktop/master/"$(dirname "$file")" if objdump -drwC -Mintel "$file" > ~/Desktop/master/"$file".dis 2>/dev/null; then echo " ✓ Disassembled to ~/Desktop/master/$file.dis" else echo " ✗ Failed to disassemble $file" fi done There are 54 files that show changes in the generated code. I didn't look through all files but the changes are largely caused by the same reasons: 1) If the refactoring introduces a change in the number of lines, the __LINE__ macro used by elog.h will cause a change in the disassembly. This is the reason for the majority of changes. 2) fuzzystrmatch.c: contains a functional change. We allocate 1 byte more now but that is safe, see [1]. 3) pg_buffercache_pages.c: Functional change. Type used in palloc_array() changed from uint64 to int, as the rest of the code only uses an integer. 4) trgm_op.c: Contains arithmetic expressions in the calls to palloc_array() where now the brackets are placed differently, e.g. sizeof(type) * a * b vs sizeof(type) * (a * b). That's the reason for many differences. So reviewing this patch can now be done by only going through all files that have changes in the disassembly. This is only 54 out of which most are because of changes in the number of LOC or where the brackets are placed. [1] https://www.postgresql.org/message-id/524587.1764365323%40sss.pgh.pa.us -- David Geier