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 1qjFVh-009zDC-SY for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Sep 2023 08:58:10 +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 1qjFVf-009zdR-1e for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Sep 2023 08:58:07 +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 1qjFVd-009zcz-Ri for pgsql-hackers@lists.postgresql.org; Thu, 21 Sep 2023 08:58:06 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qjFVa-005mPC-CZ for pgsql-hackers@postgresql.org; Thu, 21 Sep 2023 08:58:04 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 6F1103200935; Thu, 21 Sep 2023 04:57:59 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 21 Sep 2023 04:57:59 -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:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1695286678; x= 1695373078; bh=hn8jbQ3F0fiF6YZXOF4zj/qhj5/K7jtj1x4XLM72Dv4=; b=C mAM9XFlRXInkz6BCboboZ8gxXw3CdNehStiy3E8d5HOqa818MOyJ6VaV2p2d4oJ8 uY+flWWnb1yM6Sz/5yLoNVUNNkC0TXhHqUUia2Q30Ouv/fj8kn8E73hXD6mJnGMG N/tpG7cLN5cweJ8Q+MnVS8N1HSyJX3rUz5aPQncCYxhKEPEAv3yThLmr1XpzxVh8 yYi/lYwK4eXt/D5vc89NrskRPXlM5vonGG3eL/lF15EbYbgw4vOkw3cRf243sASo 8zZTMbo3CYCNDRhzeI0TAhkoaypTp3RI2ejOx54vaSRZ8xkcf1b5owz1AurxwOsE +TScygG9tOBJHK0h3PRVg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekiedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeek fffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Sep 2023 04:57:58 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 97DFDC5; Thu, 21 Sep 2023 10:57:54 +0200 (CEST) Date: Thu, 21 Sep 2023 10:57:54 +0200 From: Alvaro Herrera To: Amit Langote Cc: Andrew Dunstan , jian he , Erik Rijkers , PostgreSQL-development Subject: Re: remaining sql/json patches Message-ID: <202309210857.3i4xp5oojokl@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 I keep looking at 0001, and in the struct definition I think putting the escontext at the bottom is not great, because there's a comment a few lines above that says "XXX: following fields only needed during "compilation"), could be thrown away afterwards". This comment is not strictly true, because innermost_caseval is actually used by array_map(); yet it seems that ->escontext should appear before that comment. However, if you put it before steps_len, it would push members steps_len and steps_alloc beyond the struct's first cache line(*). If those struct members are critical for expression init performance, then maybe it's not a good tradeoff. I don't know if this was struct laid out carefully with that consideration in mind or not. Also, ->escontext's own comment in ExprState seems to be saying too much and not saying enough. I would reword it as "For expression nodes that support soft errors. NULL if caller wants them thrown instead". The shortest I could make so that it fits in a single is "For nodes that can error softly. NULL if caller wants them thrown", or "For soft-error-enabled nodes. NULL if caller wants errors thrown". Not sure if those are good enough, or just make the comment the whole four lines ... (*) This is what pahole says about the struct as 0001 would put it: struct ExprState { NodeTag type; /* 0 4 */ uint8 flags; /* 4 1 */ _Bool resnull; /* 5 1 */ /* XXX 2 bytes hole, try to pack */ Datum resvalue; /* 8 8 */ TupleTableSlot * resultslot; /* 16 8 */ struct ExprEvalStep * steps; /* 24 8 */ ExprStateEvalFunc evalfunc; /* 32 8 */ Expr * expr; /* 40 8 */ void * evalfunc_private; /* 48 8 */ int steps_len; /* 56 4 */ int steps_alloc; /* 60 4 */ /* --- cacheline 1 boundary (64 bytes) --- */ struct PlanState * parent; /* 64 8 */ ParamListInfo ext_params; /* 72 8 */ Datum * innermost_caseval; /* 80 8 */ _Bool * innermost_casenull; /* 88 8 */ Datum * innermost_domainval; /* 96 8 */ _Bool * innermost_domainnull; /* 104 8 */ ErrorSaveContext * escontext; /* 112 8 */ /* size: 120, cachelines: 2, members: 18 */ /* sum members: 118, holes: 1, sum holes: 2 */ /* last cacheline: 56 bytes */ }; -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "Nunca se desea ardientemente lo que solo se desea por razón" (F. Alexandre)