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 1rBOpf-00Aivw-ON for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Dec 2023 00:35:07 +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 1rBOpb-0030Yk-Up for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Dec 2023 00:35:03 +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 1rBOpb-0030Yb-Km for pgsql-hackers@lists.postgresql.org; Fri, 08 Dec 2023 00:35:03 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rBOpZ-00AdxQ-26 for pgsql-hackers@lists.postgresql.org; Fri, 08 Dec 2023 00:35:02 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1d0538d9bbcso14045985ad.3 for ; Thu, 07 Dec 2023 16:35:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1701995699; x=1702600499; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=wmaYLGnyp2iP/dhuEpJCo8H+inxoAQfPcL5U++gPJSY=; b=2LVvuOE6bWD1endhQ8zMMSBr179ceBp+DSU0qmBtwBKo91myX7zqaPnyTtWIkijo9g Czn57iiNd1mg72oOpOcS79Ct66Ozd8+RUEhv34ng+lFSw/Io2waElfCFyyF70t10SPEl OgtWThsaSjDjNSbT32rpml9CNjLqOtv27UEbpBToOuBsFLS4/vCdPRmdlDhvrjcRr+jq vCVc1M1lGNufE2PhKgjIcPAgSr8VKY74AxcNHAQlGXKh2rPDCkj6Gb5/UwQeruzGfWdX JVdESWFJPgH1HoJ3PROOgrtBwkqOJ8hmQdw787DSfh2qxH7GCxNbZMgAoeKlVDjLx+6B dYOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701995699; x=1702600499; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wmaYLGnyp2iP/dhuEpJCo8H+inxoAQfPcL5U++gPJSY=; b=oU3YTCW/Np560mnxg0rnGjgehWm1Vsi8yp3Zx6oDGUwg5nkRHC2HL9/GmlERvvN1Bo vJVm9siMD9sG/vpycVrpn/MNAc0yx8u4kEI2X+w4fri7Wsoc6JkQ+b23HyNQxf7cRWPC un2HgclJJLeRqlk+xDvCGBycqWRQpiTSHJzgvlEt8x2Z5R+i/o5L3Xd9IPfRDR66qkfF 0FK6hhIRLp9qDErMG4WqJZqw4VOcTcAZtYEphGvnQ7hy41KyCKmB4EfbOGZhDeXMAoO/ uo9vur4gYbChWRm1c3L2zsEhvfizdoxKRbGYeyl/VKdNftyVcj8WyqY7Hx9FQH4+borb wiUQ== X-Gm-Message-State: AOJu0YxzyVQA3w0fDZ9kqE+8fSfr9W5lExzsY7dR69hWg7YsPJKEGiaY z22Z5oB+Q9M/oUs6QMscSg7/sQ== X-Google-Smtp-Source: AGHT+IEcSd3aYZWN+iPY27/V5+lxaW0CeI8m4vXhbVuF8Tq+kRkTUpxAboY9EVzwxStQIUgv2bbTuw== X-Received: by 2002:a17:902:ab98:b0:1d0:6ffd:e2e9 with SMTP id f24-20020a170902ab9800b001d06ffde2e9mr3520144plr.131.1701995699160; Thu, 07 Dec 2023 16:34:59 -0800 (PST) Received: from [172.18.10.36] ([12.126.244.130]) by smtp.gmail.com with ESMTPSA id jc3-20020a17090325c300b001cfcf33a880sm407729plb.281.2023.12.07.16.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 16:34:58 -0800 (PST) Message-ID: <3750ff9c2a5556808827e7fc5bcc0bd16e9facf4.camel@j-davis.com> Subject: Re: Improve WALRead() to suck data directly from WAL buffers when possible From: Jeff Davis To: Bharath Rupireddy , Andres Freund Cc: Dilip Kumar , Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org, Nathan Bossart , Masahiko Sawada Date: Thu, 07 Dec 2023 16:34:57 -0800 In-Reply-To: References: <0d84c025e38673cb575dcf4987d050fe7b1e1a1f.camel@j-davis.com> <20231011224353.cl7c2s222dw3de4j@awork3.anarazel.de> <5c6e8e60c5c156a9f51ccf850f70829e45a985a1.camel@j-davis.com> <4132fe48f831ed6f73a9eb191af5fe475384969c.camel@j-davis.com> <20231104004348.zhxzk2p266i3r2z2@awork3.anarazel.de> <20231109205836.zjoawdrn4q77yemv@awork3.anarazel.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2023-12-07 at 15:59 +0530, Bharath Rupireddy wrote: > In the attached v17 patch 0001 could impact performance could be impacted in a few ways: * There's one additional write barrier inside AdvanceXLInsertBuffer() * AdvanceXLInsertBuffer() already holds WALBufMappingLock, so the atomic access inside of it is somewhat redundant * On some platforms, the XLogCtlData structure size will change The patch has been out for a while and nobody seems concerned about those things, and they look fine to me, so I assume these are not real problems. I just wanted to highlight them. Also, the description and the comments seem off. The patch does two things: (a) make it possible to read a page without a lock, which means we need to mark with InvalidXLogRecPtr while it's being initialized; and (b) use 64-bit atomics to make it safer (or at least more readable). (a) feels like the most important thing, and it's a hard requirement for the rest of the work, right? (b) seems like an implementation choice, and I agree with it on readability grounds. Also: + * But it means that when we do this + * unlocked read, we might see a value that appears to be ahead of the + * page we're looking for. Don't PANIC on that, until we've verified the + * value while holding the lock. Is that still true even without a torn read? The code for 0001 itself looks good. These are minor concerns and I am inclined to commit something like it fairly soon. Regards, Jeff Davis