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.94.2) (envelope-from ) id 1s9iyB-004b1h-DR for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2024 10:13:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s9iyA-00FZMB-OG for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2024 10:13:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s9iy9-00FZM3-Of for pgsql-general@lists.postgresql.org; Wed, 22 May 2024 10:13:14 +0000 Received: from mail-japaneastazolkn19010000.outbound.protection.outlook.com ([52.103.43.0] helo=TYVP286CU001.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s9iy2-001QvW-Ca for pgsql-general@postgresql.org; Wed, 22 May 2024 10:13:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g8W68PwZGFNnyh74cNZwK1dntdYd4+RbDFVfaS7O2OcaW5Xq8M3QcKfDpJ66kpSXFtC0gdTwQwRw67uNdlBKumKsHphujTMIn0/r4eZtkYgxOpDW7/TzG5UfRnusowflvcq20dDlt0XqI9DV1FJFpvZ00PjBSu+W+6fn2BF2WPEfM9O1H4AT7uPOU7tfDVQEb66tISth9BbkAYAVPbpHizqWoWEmYNocFJF7CXgma3sPQRmUYcdzFvgXaYTvUZZcVuf0vt9NCJevWOPXZA0262vC26IiR+fh1dYSjcIF7S+mvYErofWvEy6dmaPMDsuhSq45yrrI2WpiGqnGaw/tCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=G9r/Yc+EahWsRizm5jZTG8fXGGpquHuVf6NG8IQVm/4=; b=MbhzPjVPJc2aWzH9zOdntBzJvFpJSTix+5EX1WkI1ZcPmnO4Hz7ZskGks+LrMFMFrCL6dI30EkFt4ZH169QimabmHNcFrwQeJJk+Gjunrv+jzM429uPpL4hfFcoowUM1Q+G2kxId1g2S3p0X9Qw1blSgJ+150JY7kqMC9XJ5bJV5POLTOcrqO1RdNedyX6FJ8mQuTtCALBg0dip20yljcaTmNiE/x+qkcUDfUCq55gA0TiX4t6RN8dk/SVYafqusnkbsfje3Iz7+XvzqTzyR46rjpwKd4rLLCJLSL71zDPuNwHHgJKy3BLhObmDVHdmG3dAbBCg61pv3189e1Pni8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G9r/Yc+EahWsRizm5jZTG8fXGGpquHuVf6NG8IQVm/4=; b=CZ3y6Xni59+SBfNu2NyfhT+H6olJbLLvS2nin+J7xUHzOyDHC3jya57Fw3pVOk8xK/Svc8+s1RKZW49XZPbErcDGOPyOXZQZ+Gf1jEtTRKxxRHPGSoD7tgCC+E+nRqm9duAEq3Sd18TRs6hnrAy28t9ZnF0Q52zfJJ8s7zWnlvdXDMeEUUiejdHlVyf7j2xMLZfAIr2grhaMTThx6Cuk8sKFz2HnXMg00AhtiM77aBEiprHdg+JvbULUIpGyDCEgsoYWcM4ZrSMQcqjzVCHuX8KQUfzh4zF2HdNEyvTcukgLrm8Swk8ZOOSRQSdKJgvVbZDu5aSEcVSOut1hrlvWTQ== Received: from OS0P286MB0163.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:a9::15) by OS3P286MB1711.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1bd::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.19; Wed, 22 May 2024 10:13:02 +0000 Received: from OS0P286MB0163.JPNP286.PROD.OUTLOOK.COM ([fe80::be4b:2fd9:5414:c8bf]) by OS0P286MB0163.JPNP286.PROD.OUTLOOK.COM ([fe80::be4b:2fd9:5414:c8bf%3]) with mapi id 15.20.7611.016; Wed, 22 May 2024 10:13:02 +0000 Content-Type: multipart/alternative; boundary="------------4ZgneKJ9jN46T0e45OBMhYUz" Message-ID: Date: Wed, 22 May 2024 18:12:57 +0800 User-Agent: Mozilla Thunderbird Subject: Re: Missed compiler optimization issue in function select_rtable_names_for_explain To: Daniel Gustafsson References: <05C4ADF5-5E8C-49EC-8E0A-804BB946F1C7@yesql.se> Content-Language: en-US Cc: pgsql-general@postgresql.org From: XChy In-Reply-To: <05C4ADF5-5E8C-49EC-8E0A-804BB946F1C7@yesql.se> X-TMN: [AbpYFH60Lhv5vAbH6rg2Dxyjll4sZB5e] X-ClientProxiedBy: SG2PR02CA0042.apcprd02.prod.outlook.com (2603:1096:3:18::30) To OS0P286MB0163.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:a9::15) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS0P286MB0163:EE_|OS3P286MB1711:EE_ X-MS-Office365-Filtering-Correlation-Id: 600a1070-8dfc-46f8-f668-08dc7a47c38c X-Microsoft-Antispam: BCL:0;ARA:14566002|461199019|440099019|3412199016; X-Microsoft-Antispam-Message-Info: pnNFeQzevNxtINy5xl9PJifzhVGEsd2yQcKvrjPmpusJwbST/T+LQfB2I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xNQmJYcUJGQVRvNFg4OU0wTUExWTMvMUtMYlJx?= =?utf-8?B?eEYvbkxrK1FlVWVwbEtRVXVkUVhIM0xVK2EzM2RwY3puU2FadFJPLzM4dTVy?= =?utf-8?B?SHBRcWlMVGJDY1lHMHhUR3Q4c0tVZmhoVWJHUUdnQVpQeTVnUHl6NytFa0Rp?= =?utf-8?B?VStTNk1jOUdFSlZ0OUVMSE9FQzJ4b01JK3pmMG10RFBWMVR4ZUtoc0Vxd3BV?= =?utf-8?B?YkNjRERDZFNITWFEcU5rdnhhdHhvQ0Y1ZS9YakdyeUNOeUtzaGl2R1VzdEg2?= =?utf-8?B?R1pCcVFaYkRiUTNrYkVRQkVYYXdCMEhET0s4Vlcxa0V1aWJWc2c4dFNXVEdx?= =?utf-8?Q?9qxfuDcjdjWOIGAUktQIGA1pImY0JCid3qu+uOOYLFJY=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 600a1070-8dfc-46f8-f668-08dc7a47c38c X-MS-Exchange-CrossTenant-AuthSource: OS0P286MB0163.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2024 10:13:02.4079 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3P286MB1711 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --------------4ZgneKJ9jN46T0e45OBMhYUz Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit > How is the memset in select_rtable_names_for_explain a dead-store? > Even memset > calls could be optimized away from the EXPLAIN codepath I have a feeling it > would have to be many in a tight loop for it to be measurable even? > > -- > Daniel Gustafsson For the first question, I don't mean that the memset is the dead store. I mean that the stores with value "0" after the memset are dead: ```     dpns.subplans = NIL;     dpns.ctes = NIL;     dpns.appendrels = NULL; ``` since the memset has written zeroes to the object "dpns", and these members are known to be zero. For the second question, you are right, I don't really profile it or measure the performance impact for it. I just think it's worthwhile to improve codegen quality without affecting readability, as adopting performance tips from some static analyzer. Best regards, Hongyu. --------------4ZgneKJ9jN46T0e45OBMhYUz Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
How is the memset in select_rtable_names_for_explain a dead-store? Even memset
calls could be optimized away from the EXPLAIN codepath I have a feeling it
would have to be many in a tight loop for it to be measurable even?

--
Daniel Gustafsson

For the first question, I don't mean that the memset is the dead store. I mean that the stores with value "0" after the memset are dead:

```

    dpns.subplans = NIL;
    dpns.ctes = NIL;
    dpns.appendrels = NULL;
```
since the memset has written zeroes to the object "dpns", and these members are known to be zero.

For the second question, you are right, I don't really profile it or measure the performance impact for it. I just think it's worthwhile to improve codegen quality without affecting readability, as adopting performance tips from some static analyzer.

Best regards, Hongyu.

--------------4ZgneKJ9jN46T0e45OBMhYUz--