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.96) (envelope-from ) id 1wAOYH-002L5z-2F for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 08:46:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAOYF-0069l2-2Y for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 08:46:20 +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.96) (envelope-from ) id 1wAOYF-0069ko-1J for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 08:46:19 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wAOYD-00000001Bot-0veX for pgsql-hackers@postgresql.org; Wed, 08 Apr 2026 08:46:18 +0000 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-66c17372965so11182499a12.1 for ; Wed, 08 Apr 2026 01:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775637976; cv=none; d=google.com; s=arc-20240605; b=IJf+6u0rXikSxZj5mUDqlkEhxUX17+iw3go/DoiWTX4tiSdyIc/2+cPSboG2nmysCE ikhX1LmdsRHbFHGN4wptotzgY5AZDQZtOIEjFSEpp+4O2j9SE22Nh05AZ5NAl2HS40mX HAl0RNw36KqdiPs6PYf3YhCitiNliL/CRNfPMkYGbJfYaIaOw5Wc7vEWrHRkrgIX4AlU AoId3MYzoTS4lO26NNFBj5ZVrZKxYx4VJfqDQ7jlOXv9DIX52JaADXFGOiyg6sJf3Rwk Jmf3jxR3OdyZbHqvk2ynAQAvbCYRrEbMwYdEDq1lr4bY0kRQBcexF/9ANRYrMhcy1EGO iZhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=FTvF1mMW2gkpHAdqUFh64eu7daNNwEd/a7lzPX45iQE=; fh=fQHvnwXhgqG6tBW3h3fPKxa7faaLRlUC10GqhKEmno4=; b=OH874RUtZvXg0GpxAP2nd/K0VWLXhEic4colRgikBdY3250VoG0ofQD2UoPzqyaMSF G6yIkxbRKiozFUpsag/PiVT+PKfZYeBaAguwg248EMQvCIGqpOze6wuOKUxt4F4WNpLR +RHQSizbAcI5f5nlqwTG7TBw7qUd2bZdC+BwCpTeMHgVIWAnhQ7lH5kxUALqu1hrmIFB 63FWX1sQOIeR/EmUSdaPjGgwlgII1IVgBYso3VskSV33FAF/NKYgHrbiRX8YZxYzy7DE xEJhpsVWFAcb+jFksrHNnyhM5YNsziNcPbFNkN2rb9CEHkwSx0BEimLkkeQMT7h2/PJK YIRw==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775637976; x=1776242776; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=FTvF1mMW2gkpHAdqUFh64eu7daNNwEd/a7lzPX45iQE=; b=DHV5d+CQ2Cr72MSasqieqIN1kca7apr/LD2QEqY5A+4aNi3dQM6ZH07PdPf8VvYqmk MaLbApFCnhpU1rMAnRttMUHIW6nzqKav8/rJc6TgH3CaBjQUXJkvylxyjC4t9uUP3G6B xd6KjklL15RHoOr1MAVk5AsnkVCAINy8+bf3h/K9eIryC0niIWRGuAJP5KTukjDovdK/ eJwQXhuXLDWDMRQbblxCTqNjCAIRvfXSkmeqKzECMuq2tbLAspnr1yw6ygD9NGrRiWUi ECeCEBEYBnQEgd6kyDC7+z1pb7VVtvZyYsBB4fk4rFw1/WvXq8EFWoqP/UtAs1kb8rlH 60Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775637976; x=1776242776; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=FTvF1mMW2gkpHAdqUFh64eu7daNNwEd/a7lzPX45iQE=; b=EE7DJr1EuYxpNrygADe5o5FvO2JoYrlqRd8mCsesxHIJd9cYEnjvvkojoWTvaApO1o zWkKRhvHT47yZVJ9KlTIDRn5wQFkOXE1qsAeRNNnwzQvzWZszLu8E6DLeirC5X8XtXA0 lDM5PGrMWOO2TutEHljt8HoIrTzGC+vcyRfgT3AFSD12GUqMGTjqFQ6UGdjfuIt7zDGG izopcaZmOdqxaM7hqqg/jdHgBJI+TMIJqZa9aNMFWiEKuiptvRVmi690qu6Dukl3p/Sg RO8oXpXRO75rhmjKX/IqdeXHIPOjY12Zm/4MwkHI7eee+ggC4IZtJGa3G0FqLV3l6gz8 UI7A== X-Forwarded-Encrypted: i=1; AJvYcCVy9IIVeQ4e9qcEaVhy2uRAIFax6G2L7vTrZB6CH68ON7EGIo+qwG9Ebo5mwIHS2wwuCVIF4iF+kIPisX/B@postgresql.org X-Gm-Message-State: AOJu0Yx0PyJUeqh6ZzJWNqo6LMt/sBkAi7wylXzCxUr9+PTHNMZTa08Z ADOb3bA8etgfRm8CZALtG6DQtW+Gaaa9p2r/QM64FMjB76JWNxDPeG4pokre1ctF5diV3buqtqf D8HCyluD+7TGmDR/ObnSs7SXItqMpIr0= X-Gm-Gg: AeBDievLgg+3KHRMv8IfHau6aCUmtglElnPfrajaJ0hHlw2+ejR6xPvnWCnukHziZ4k 9itsq5A041u4hyRzP7ggFlYdzoenjcvJrUQkMYeoLpLQI9iNS1ts7xz4cgpTo5Ax/fSov6n05Yc 3kDIdN2ULBJ7xfjHStD+nG3p/0ZQ1Qt9r+kVjtyvnerV+1Md01OfFXjax22ze8Qz42cpOI+dOLO dXmouurMGXlWSqx6Z0SZnmB9ULMV71PB/L9NPT2riQ4jfOC6NmKXP+ls/Zkjw1bGIZcXrKr2QvY 6ZO8nuLdRJy9cBZ9 X-Received: by 2002:a05:6402:2354:b0:66e:de5b:d9c0 with SMTP id 4fb4d7f45d1cf-66ede5bdb9fmr6472221a12.17.1775637975774; Wed, 08 Apr 2026 01:46:15 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Imran Zaheer Date: Wed, 8 Apr 2026 13:46:04 +0500 X-Gm-Features: AQROBzDId3B0lUfe5hZLq-zcGm7JLkCrAJI_C7s33ni8WB4GJ9PC10U9PHPvC5g Message-ID: Subject: Re: [WIP] Pipelined Recovery To: assam258@gmail.com Cc: Xuneng Zhou , Zsolt Parragi , Jakub Wartak , "Hayato Kuroda (Fujitsu)" , pgsql-hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > > Hi Xuneng, Imran, and everyone, > Hi Henson and Xuneng. Thanks for explaining the approaches to Xuneng. > > The two approaches target different bottlenecks. The current patch > parallelizes WAL decoding, which keeps the redo path single-threaded > and avoids the Hot Standby visibility problem entirely. > You are right both approaches target different bottlenecks. Pipeline patch aims to improve overall cpu throughput and to save CPU time by offloading the steps we can safely do in parallel w= ith out causing synchronization problems. > One thing I am curious about in the current patch: WAL records are > already in a serialized format on disk. The producer decodes them and > then re-serializes into a different custom format for shm_mq. What is > the advantage of this second serialization format over simply passing > the raw WAL bytes after CRC validation and letting the consumer decode > directly? Offloading CRC to a separate core could still improve > throughput at the cost of higher total CPU usage, without needing the > custom format. > Thanks. You are right there was no need to serialize the decoded record aga= in. I was not aware that we already have continuous bytes in memory. In my next patch I will remove this extra serialization step. > Koichi's approach parallelizes redo (buffer I/O) itself, which attacks > a larger cost =E2=80=94 Jakub's flamegraphs show BufferAlloc -> > GetVictimBuffer -> FlushBuffer dominating in both p0 and p1 =E2=80=94 but= at > the expense of much harder concurrency problems. > > Whether the decode pipelining ceiling is high enough, or whether the > redo parallelization complexity is tractable, seems like the central > design question for this area. I still have to investigate the problem related to `GetVictimBuffer` that Jakub mentioned. But I was trying that how can we safely offload the work d= one by `XLogReadBufferForRedoExtended` to a separate pipeline worker, or maybe we can try prefetching the buffer header so the main redo loop doesn't have to spend time getting the buffer Thanks for the feedback. That was helpful. Regards, Imran Zaheer