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 1taGsT-000JKf-RY for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Jan 2025 16:13:22 +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 1taGsR-0013E9-Tv for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Jan 2025 16:13:19 +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 1taGsR-00136j-K5 for pgsql-hackers@lists.postgresql.org; Tue, 21 Jan 2025 16:13:19 +0000 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1taGsP-000kxu-1n for pgsql-hackers@lists.postgresql.org; Tue, 21 Jan 2025 16:13:18 +0000 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-844e161a957so448910739f.0 for ; Tue, 21 Jan 2025 08:13:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737475997; x=1738080797; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rMiP9hgd7PebWUzZtpCVrc3Z/pCELa377Z57dp32Hi4=; b=T6/MpvDiRmkAOahNksAhLgBGqXWdr6QLYGiBjTKUe0XoO5w2QDdWD890zVxJ7q0vNE zCVB15eEFKhb5OOoTZDLaoEiWTqURuy/kc4lTceGwVy84tNa5DCo6h4kKdUfsO9lN/ru pJXwp7zn8fl0EMka0Y3BLZri+ig68pNu3LtpVMOhefHlhDUDVz3M4HhNsm4xfQSv6LRX Fpsc84rrFvPklc4L5Ndxp0anhgUQv850RPXcVABNYc0HyNke3hCabjAgwj3Y9KvGDQ0M LutXv60k5x0h5qKrSmefoqqsTN3NTWbkuQl8orgHxGicLPeLjchV3ONcVtfPidFeyj7X vYwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737475997; x=1738080797; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rMiP9hgd7PebWUzZtpCVrc3Z/pCELa377Z57dp32Hi4=; b=FuzCjr0BVXYxBkuBSKrBJk67eg7TsVEpYF0TC7q9bOAOyfceSlnFUxQOHZ2P8ayZV1 wwC+eJq1Z2eGDZRbgAlJvyjlX7Tf8aHsPWR4PHJxSqAK8IPX7xEqswCB9jLTBx4jLC2Q nWW3ThTkHx5kVy701H9yR4fWYfnSpkZq36/3t+6Ty2+7lXBJH2so4+NkAYgOyckI1dWf OUrtNFWTK/3hwcYgcFrAeDvRvDHMvTb0BlXvhxk6PpK5ZxshRZ/fc4BEgyEAXwF6YoMz 91U5YTCsyoTIPsLADqt/SSjgUp6+GUiXCSSsuAWFdB3E+jg9u9B9wCavn588plH3wQtY CK7A== X-Forwarded-Encrypted: i=1; AJvYcCX9IcGoY9IEUoQiUSPcdPRmPZSGYfvVFpUTrKpsvRpobKn/F6626WJMgtvpKOQIXmxisRyIrNpVEKRw65rc@lists.postgresql.org X-Gm-Message-State: AOJu0Yzz6pw7/Y0zpDHeERvQwiCcspqwSbf4X/UYeCDPaFKrHpn20lcz 7T9aXUmYqpPhnuZ9pnCpSc6ObdESTM3G9QZ6g+MR8zRQbYu9xlmH X-Gm-Gg: ASbGnctHNoDv99BL/bEFaR8oK1Vq0EGmxK3CECxqaKgBWmltz1OBb1qQP1W0usIX4jr CucfmYh03Ob6Ip1c/s+CF8EClj0kRx9Mj4Ub9t0zxE61xfut0YW7qEIoOuociqyZalgr6aKN4gv G5lEP6c+921h/ZogaBG7EOh5aoIGqeoGnqb3+o1wA1dINHdGJ2Vi+3l3pZSnCVEt9LAsg8zTGHH EpeWv9A6+Mu42LrCNDsKRFqdspkoPa7sTAgsSzwViuDz5SkKC7DLlVyGGyVcPNoGWXNQo8bXCFy MateC2QzbjBiGE0ckIfSBLg2lKmFGBJq2Wz5RxYYxoTGzV0Eu2woeFp9ZWKc X-Google-Smtp-Source: AGHT+IEdy0BXzmE9kIoe/B1gTwVX+8VTdD59rEbpz9ju4knShbRr0vowiD4S5xrsHzXwNvUJ/GA8eQ== X-Received: by 2002:a05:6602:36c3:b0:82c:e4e1:2e99 with SMTP id ca18e2360f4ac-851b651909fmr1417747439f.11.1737475997355; Tue, 21 Jan 2025 08:13:17 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-851b01f2b4esm318252739f.16.2025.01.21.08.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2025 08:13:16 -0800 (PST) Date: Tue, 21 Jan 2025 10:13:14 -0600 From: Nathan Bossart To: Andy Fan Cc: Justin Pryzby , Maxim Orlov , Pavel Borisov , "Bossart, Nathan" , Maxim Orlov , Andres Freund , pgsql-hackers@lists.postgresql.org Subject: Re: Pre-allocating WAL files Message-ID: References: <163352276350.15435.3988688227048304232.pgcf@coridan.postgresql.org> <20220301144044.GG25269@telsasoft.com> <20220301150704.GA1030078@nathanxps13> <20220317231212.GB1415284@nathanxps13> <20220408203003.GA1630183@nathanxps13> <87sepc4zcg.fsf@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jan 21, 2025 at 09:52:51AM -0600, Nathan Bossart wrote: > On Tue, Jan 21, 2025 at 03:31:27AM +0000, Andy Fan wrote: >> 3. Why is the purpose of preallocated_segments directory? what in my >> mind is we just prellocate the normal filename so that XLogWrite could >> open it directly. This is same as what wal_recycle does and we can reuse >> the same strategy to clean up them if they are not needed anymore. > > The purpose is to limit the use of pre-allocated segments to only > situations where WAL recycling is not sufficient. Basically, if writing a > record would require a new segment to be created, we can quickly pull a > pre-allocated one instead of creating it ourselves. Besides simplifying > matters, this prevents a lot of unnecessary pre-allocation, since many > workloads will almost never need anything beyond the recycled segments. That being said, it would be nice to avoid the fsync() overhead to move a pre-allocated WAL into place. My first instinct is that would be substantially more complicated and may not actually improve matters all that much, but I agree that it's worth exploring. -- nathan