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 1s9qJJ-005TIy-P0 for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2024 18:03:35 +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 1s9qJJ-002Glg-SJ for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2024 18:03:33 +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.94.2) (envelope-from ) id 1s9qIb-002A9S-U9 for pgsql-general@lists.postgresql.org; Wed, 22 May 2024 18:02:49 +0000 Received: from fhigh1-smtp.messagingengine.com ([103.168.172.152]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s9qIW-000Erd-AP for pgsql-general@postgresql.org; Wed, 22 May 2024 18:02:49 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 946B411400C2; Wed, 22 May 2024 14:02:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 22 May 2024 14:02:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1716400962; x= 1716487362; bh=Y4rmfAysYHTcgvISrdCAMlDGU7RdlbQR/klS+Y2KnIM=; b=A fnIibKIjNUv7zvgN3LYYs/7tWKVmx7tuZ+cs8QvDkzoWfsraUK6DyLsMecE4YRYE rB1VNXZFV9mBCLF81ljgsM8Nvuf8bKvyF7jcEbGL4Io5dxlD1e4wkctSagVZlRU1 I7h17Dze2/OgioLGRrahrmol1A/sbTUQRMwoU/NWpMgOchxAaE/pz11lKy4VROD2 M8QEHu+0M6zYO66aLUHsGS9yGqPf0ZNWir8NzAgzDqvSLF/FbpYLnvg0vGEJwth5 5xMuxrgUVbzOXtcrgZHkuWlKDC5cbzAQd6N+tCFSZdzigYjb2VYwkqXeCAOn8Qcc dceRb/pSqdCn0c7/j8MRg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeigedgfeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfggtggugfgjsehtke ertddttdejnecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhr vgesrghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpeelueeihfffvd ekteegueevhedvfffhhfdvgedvhfduieefffffjeetheeutdekleenucffohhmrghinhep ghhithhhuhgsrdgtohhmpdgvnhhtvghrphhrihhsvggusgdrtghomhdpphhoshhtghhrvg hsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 May 2024 14:02:42 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1716375612; bh=l4SN28poAQNg20MMJu0z5UwOXmnZ9gSvAMyop291bZg=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=MitXIuWp4KEzHIK3C0eaEsxWmxNVMxclI/TandhGiO9wTBRNylRKgHgKsoHYyFW4w 7ZBbSl7IpcDbPJQL3PHWbIWcPxra1DSJf9VJdHktSjr8heb73PJztFlk3XRidjpixl NoI7luRjmcyi+yoxHTpa5UT3pCEDMSNYehuupD2rxTD27hs0Ni+bJVj31wYuaDLjAd tz9+tyJS+54cpIpgYbOICXO2MK2FJRODiNLX7xHPbt3izPP+EpNMSpD6DgFzFioVOf KoCBwxCXascU/2mVPovEpgVzDdwdvdtAyVpoEEUWGu6oJEUIALDbW0ARPfyUubDiXE TZ/dly4DKB7kA== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 555183C3; Wed, 22 May 2024 13:00:12 +0200 (CEST) Date: Wed, 22 May 2024 13:00:12 +0200 From: Alvaro Herrera To: XChy Cc: pgsql-general@postgresql.org Subject: Re: Missed compiler optimization issue in function select_rtable_names_for_explain Message-ID: <202405221100.fy66dsew2f52@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-May-22, XChy wrote: > Hi everyone, > > I'm a compiler developer working on detecting missed optimization in > real-world applications. Recently, we found that LLVM missed a dead store > elimination optimization in the PostgreSQL code (https://github.com/postgres/postgres/blob/master/src/backend/utils/adt/ruleutils.c#L3794) > in the master branch. I think if we want to improve how this code is seen by the compiler by modifying it, we should just remove the NULL/NIL assignments. It's a pretty arbitrary (and rather small) subset of fields being initialized, fields which very obviously have been zeroed by memset already, so I don't see any value in the explicit assignments. The criteria may be different in cases where some struct has all of its members initialized to something, because at least you can use that kind of thing to find places you need to modify when adding new struct members. Not so in select_rtable_names_for_explain. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "I can see support will not be a problem. 10 out of 10." (Simon Wittber) (http://archives.postgresql.org/pgsql-general/2004-12/msg00159.php)