Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cYGmP-0006lG-37 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Jan 2017 18:34:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cYGmO-0004r5-JN for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Jan 2017 18:34:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cYGmN-0004ql-HE for pgsql-hackers@postgresql.org; Mon, 30 Jan 2017 18:34:15 +0000 Received: from mail-qt0-x22e.google.com ([2607:f8b0:400d:c0d::22e]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cYGmI-0007TJ-By for pgsql-hackers@postgresql.org; Mon, 30 Jan 2017 18:34:14 +0000 Received: by mail-qt0-x22e.google.com with SMTP id x49so211152659qtc.2 for ; Mon, 30 Jan 2017 10:34:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=6K4GALGWgdYPRpkKtXWQjUQqKKjtdZhELbpTLloWlLk=; b=CwVUWikUyFtIofwl2ck8O8+FO5KnpnpRQNgHXBvt+r93FS1R5e6H5jc52czzhLoboU WZLIRL2ME1ugftlr9DpmcHI7HaKbmcMO+TnC6RrXIrxWutW1zkxuZ0lgwoGXAJ8CGLZR nbDFze4cm1mGSvUbcy4OJ7qD9y5+b1i4MU4KscMKsbVhhp+CM6cu7Q85u3813A0K/hpO ClkWhCXlZykFz9cwdxfElv/EexQtH8SXPGf1g8856Gk9sCxZ7HxCc8UKS02qWJUptRqZ ELV02r/W2guETviHge0Y0wPltLx9hclZjBZ8tX8gt5h+ep3+dCBplnH9oKMThQ9gWOHA pX8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=6K4GALGWgdYPRpkKtXWQjUQqKKjtdZhELbpTLloWlLk=; b=tJ17/+iRA8PZDIbC8gTOEkwog9VII6NZTfNm+tSwrXTVZElfRc173x/gS6wLYUyEhP mnrkRNl3njgcMw+bGx+QpkIfa3/VKGqrb7zzzifVOd2UaVCqGLH6TxDmVGVuBstTnLf7 Oc6amUROphJpHlQuR0Ovk5Fevu7wEKnL19tKt+/Ik6p1x2CxTsV5vpZwdFhOQ7Myi9dI 09dVfxBZy8F+6W8Pc+RQ3ZLcfjnWD9uTqTsefsWhhHRcpVDJ+ISqdvybP8F6a+Wp+6Ix c8BW+Wz4U17Fq1gt/f/u4rUHkdSelONLQDkNwEfboFNHrb9TvmqeSlyh7QNBOTqqQoEd y3uQ== X-Gm-Message-State: AIkVDXLHjCn0cU5UGlEB9E1macblKeMT3LpK+50PtAQnx8ghWvqI66WHmVRyXNmibjj/7Yq5 X-Received: by 10.200.53.70 with SMTP id z6mr22426640qtb.150.1485801248515; Mon, 30 Jan 2017 10:34:08 -0800 (PST) Received: from alvin.alvh.no-ip.org ([190.217.211.239]) by smtp.gmail.com with ESMTPSA id a70sm12957035qkc.1.2017.01.30.10.34.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jan 2017 10:34:07 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id E1FBEEF9; Mon, 30 Jan 2017 15:34:05 -0300 (CLST) Date: Mon, 30 Jan 2017 15:34:05 -0300 From: Alvaro Herrera To: Pavan Deolasee Cc: Jaime Casanova , Haribabu Kommi , Tomas Vondra , pgsql-hackers Subject: Re: Patch: Write Amplification Reduction Method (WARM) Message-ID: <20170130183405.uwl22wp25wlzdpbq@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Pavan Deolasee wrote: > On Wed, Jan 25, 2017 at 10:06 PM, Alvaro Herrera > wrote: > > > +( \ > > > + ((tup)->t_infomask2 & HEAP_LATEST_TUPLE) != 0 \ > > > +) > > > > > > +#define HeapTupleHeaderGetRootOffset(tup) \ > > > +( \ > > > + AssertMacro(((tup)->t_infomask2 & HEAP_LATEST_TUPLE) != 0), \ > > > + ItemPointerGetOffsetNumber(&(tup)->t_ctid) \ > > > +) > > > > Interesting stuff; it took me a bit to see why these macros are this > > way. I propose the following wording which I think is clearer: > > > > Return whether the tuple has a cached root offset. We don't use > > HeapTupleHeaderIsHeapLatest because that one also considers the slow > > case of scanning the whole block. > > Umm, not scanning the whole block, but HeapTupleHeaderIsHeapLatest compares > t_ctid with the passed in TID and returns true if those matches. To know if > root lp is cached, we only rely on the HEAP_LATEST_TUPLE flag. Though if > the flag is set, then it implies latest tuple too. Well, I'm just trying to fix the problem that when I saw that macro, I thought "why is this checking the bitmask directly instead of using the existing IsHeapLatest macro?" when I saw the code. It turned out that IsHeapLatest is not just simply comparing the bitmask, but it also does more expensive processing which is unwanted in this case. I think the comment to this macro should explain why the other macro cannot be used. > > Please flag the macros that have multiple evaluation hazards -- there > > are a few of them. > > Can you please tell me an example? I must be missing something. Any macro that uses an argument more than once is subject to multiple evaluations of that argument; for example, if you pass a function call to the macro as one of the parameters, the function is called multiple times. In many cases this is not a problem because the argument is always a constant, but sometimes it does become a problem. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers