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 1vvwG9-00BJq7-0l for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Feb 2026 11:43:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vvwG6-002peR-1z for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Feb 2026 11:43:50 +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 1vvwG6-002pe2-0a for pgsql-hackers@lists.postgresql.org; Fri, 27 Feb 2026 11:43:50 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vvwG3-00000001Twr-0viD for pgsql-hackers@postgresql.org; Fri, 27 Feb 2026 11:43:49 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-4398d1f06caso1816020f8f.0 for ; Fri, 27 Feb 2026 03:43:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772192627; cv=none; d=google.com; s=arc-20240605; b=BDJ9QK0SJRlUiSzpcga/pMnBJ1l+Rc21o+Et8oHMSA6LKvGVOEU5GiYH9f8Pr5NvVl P0y0KezP+/ciJGSX0ujdtUp5UI8idgQCISUY6HPtcaP+ARyD+PvB1JAm62SYAqmeiRaC nQEWB0IGpq1t40sdyjOIQQxr5rA1jcgjjEIWcQKzK24CqvlWzhPrqvEDpRYZsoXJYelv 3ZDSuBuqNUyNr7NDfDEqS6Vx4HSySHnUfGDkdQrSMHUV+jKh2Qz7IYB1dilLBLC0Wnzx Bl6vxnF8yr6NodvwoTQlft8s/Wt7Ev14QnEDOQk8ei+sTGBnozTvsHc1tc2bgj1fEZK2 qsmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=bNu4WJ7YGDhbG8sCistzfd7+8h0qHOR0549Dvw6aRYM=; fh=VLgdFq+lqMrUdEgCvJR3AliDeZNTGPXAwn3iIPU8IbE=; b=PXWZe72cOYpLJSQygS/JozWKjWA/N0FLyfEhpwjWHvCNkxN85ffK4xxh4VuDvsWTOZ yyQmlYt5i9c5tGvFwgzirGx8WyvH9LzZep+csvMigrZDT8xwHiS/FThm3Y6qGCVgS0dS 0jd3ErLZk1AwWy30aRPGAddQyGQjxyix3lCsB5bAIuoscFGxZ5xE33GFNnRbtrEfwpqG rSuosh7z/cXT8yA2YPDiBusMs28m2AJeZEcHytEFpGjJ+S9X+pSmHfmApWfD6ee2TmAM hRIMhjDX9OQ2sACweVzU/LHd0h8iyG5aNw/Z47Qq93XU1ZsjBElgeSjUVMEKm6uH3geP Q2fg==; 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=20230601; t=1772192627; x=1772797427; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=bNu4WJ7YGDhbG8sCistzfd7+8h0qHOR0549Dvw6aRYM=; b=N3OAdgM2dwQPbSMlVV93KgkPjkkgWydKcT47/dvV5kcw4e7TTyZyCqYXpS0BqAwZ3e RgGxnhPT7DDdVf+EX0KSaPenBTmmsBqWqbE0zXrhZ3WuTXr97lSQA7w1a+fhkCjB1Op+ 8STUkM2L53mCVCA2VVxVsY0ZGh79nmYUeWWhdxZOWGI6Bv/dywDSHLX6gFN9yRiYQSCS jRBjDHLaF2NbKYKolNLe9Oo2jersM7yFtrQNcPoq8T57P4xFBpHrrWzx9qDCsGoij4oM dl7EMvM/ky6RmJV0YMCdr+/ApYnXQ5Zs74pB8TdxdTo9smHvI70Dc3uN5WgjI6s54NG3 fxOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772192627; x=1772797427; h=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=bNu4WJ7YGDhbG8sCistzfd7+8h0qHOR0549Dvw6aRYM=; b=VUc1d4vI14B26032B2pB9gE3SItA+63rC32f6GEyCONq3Uez0ZfJ3CzqqrGc3clXvP 3aj7WdAJx1tldmmVE6BJyb2ROtG3wnp7KqGdusGlHn8W6OnzbtHeXZ4PC10I9lt1uJro 7R/QfUZK4y1/WasqCwb9BPVrlE9YtZQFV/C0S/+FuNaeDWWs+cvkZOj/aU9cet7EJv4D uwwwy1s2Zx5l4JtSTSojp2LVpKBRX1C/JFaq40ZBN5bnEIOqIEk5ckFbbTGzRKgpjsza v62B3e8hlQPPjYxYNR9r+x/wGYGiSZ2t17s+iXSEvCsV8ZwTOBCIm2cuQ0Crpvmkrd5a oRDg== X-Forwarded-Encrypted: i=1; AJvYcCW0iuwWgTFRXyXlreNVAzg5LTpAGzUBNYkqdg58nEcG66Cwo2DfIMi3aisf/medoiavAcoULKGPGWZYXBP6@postgresql.org X-Gm-Message-State: AOJu0YzIg3Q4ZHyWS9LYvyXACIc4ushT0Ji2Ud6/p6jKfX7GeKwmqa3n MFnRiF9m65KpPOa2o+pznMA7bUUSBF5kZM44isXDZ6LiZVwDPfH/1t8XmthfVUzXA85NzyIDGUE qW7QnJTWWPlLhe/46uhxmwBGD3UsL/PQ= X-Gm-Gg: ATEYQzyGXEV2MtOgO8jNVqLwIxtQkUjHDkvcDAWNcyB9y+//U6y8cgtZHgeO52N2kyr +MupYza/qHuJZm3WX8lB+CiO6kZxu4yORJJdYid1hU6ZPjg4ZrJCyqompv2B4o5u6Qy+QI4UjaM axw+yMlmLzBOlCpaYYYsZ95GHWWO3H+1yhvy9tJbMc8XVBjFSWGwbB+ryp3xGuAWGRmXTARxcYj WPAd39k9QRZwIjv6XMxPyWlGlTQ9LCbr9xHByCOmCeTIpjevbjnNXOYI/wso1Og/LBJ8Gs5rn+i 3LIWld+x7wdG59QLyJsfvBgXL3hRzwKwZ/MWlqQ= X-Received: by 2002:a05:6000:4012:b0:439:7e15:19d7 with SMTP id ffacd0b85a97d-4399de1c59dmr3906806f8f.36.1772192626516; Fri, 27 Feb 2026 03:43:46 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?B?6ZmI5a6X5b+X?= Date: Fri, 27 Feb 2026 19:43:34 +0800 X-Gm-Features: AaiRm53lW6NhwFE7KTKaQmP8aYpJbNxGHGo523tl1lfoKFICU799cFiMoo7Rzc0 Message-ID: Subject: Re: [PROPOSAL] Doublewrite Buffer as an alternative torn page protection to Full Page Write To: wenhui qiu Cc: Robert Treat , Jakub Wartak , pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi wenhui, Here are the latest benchmark results for the Double Write Buffer (DWB) proposal. In this round of testing, I have included the two-phase checkpoint batch fsync optimization and evaluated the impact of wal_compression (lz4) on both FPW and DWB. Test Environment: - PostgreSQL: 19devel (with DWB patch applied) - Hardware: Linux 5.10, x86_64 - Configuration: * shared_buffers = 1GB * max_wal_size = 32MB (to stress checkpoint frequency) * wal_compression = lz4 * double_write_buffer_size = 128MB (for DWB mode) - Workload: sysbench 1.1.0, 10 tables x 1,000,000 rows (~2.3GB dataset) - Method: 16 threads, 60 seconds per run, each mode tested independently (only one instance running at a time to eliminate I/O contention). Three modes compared: - FPW: io_torn_pages_protection = full_pages (current default) - DWB: io_torn_pages_protection = double_writes - OFF: io_torn_pages_protection = off (no protection, baseline) Results with wal_compression = lz4 ---------------------------------- 1. oltp_write_only (pure write transactions: UPDATE + DELETE + INSERT) Mode TPS vs FPW vs OFF ---- ------ ------ ------ FPW 13,772 - -64.3% DWB 20,660 +50.0% -46.5% OFF 38,588 +180.2% - 2. oltp_update_non_index (single UPDATE per transaction) Mode TPS vs FPW vs OFF ---- ------ ------ ------ FPW 59,427 - -57.5% DWB 104,328 +75.6% -25.4% OFF 139,870 +135.4% - 3. oltp_read_write (mixed: 70% reads + 30% writes) Mode TPS vs FPW vs OFF ---- ------ ------ ------ FPW 6,232 - -9.0% DWB 4,408 -29.3% -35.6% OFF 6,845 +9.8% - Results without wal_compression (for comparison) ------------------------------------------------ Workload FPW DWB DWB vs FPW -------- ------ ------ ---------- oltp_write_only 9,651 22,111 +129.1% oltp_update_non_index 48,624 98,356 +102.3% oltp_read_write 5,414 5,275 -2.6% Key Observations: 1. Write-heavy workloads: DWB outperforms FPW by +50% to +76% even with lz4 compression enabled. Without lz4, the advantage grows to +102% to +129% because uncompressed full-page images cause severe WAL bloat. 2. lz4 compression significantly helps FPW: For oltp_write_only, lz4 boosts FPW from 9,651 to 13,772 TPS (+43%), while DWB sees minimal change (22,111 -> 20,660). This is expected -- lz4 compresses the 8KB full-page images that FPW writes to WAL, but DWB doesn't generate FPIs at all, so lz4 has little effect on DWB's WAL volume. 3. Read-heavy mixed workloads: DWB shows a regression (-29%) in oltp_read_write with lz4. This workload is 70% reads with only 4 write operations per transaction, so FPW overhead is minimal. Meanwhile, DWB incurs additional I/O overhead from writing pages to the double write buffer file, which outweighs the WAL savings in this scenario. 4. Batch fsync optimization is critical for DWB: The two-phase checkpoint approach (batch all DWB writes in Phase 1 -> single fsync -> data file writes in Phase 2) reduces checkpoint DWB fsyncs from millions to ~hundreds. For example, in oltp_write_only: 1,157,729 DWB page writes -> only 148 fsyncs. Summary: DWB provides substantial performance benefits for write-intensive workloads with frequent checkpoints, which is the scenario where FPW overhead is most pronounced. The advantage is most significant without WAL compression (+100~130%), and remains strong (+50~76%) even with lz4 enabled. For read-dominated mixed workloads, DWB currently shows overhead that needs further optimization (reducing non-checkpoint DWB fsync costs). Regards, Baotiao