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 1tvLwi-003ntL-Ny for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Mar 2025 19:52:52 +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 1tvLwh-007kkM-Dr for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Mar 2025 19:52:51 +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 1tvLwh-007kkC-4N for pgsql-hackers@lists.postgresql.org; Thu, 20 Mar 2025 19:52:51 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tvLwf-000BqN-1d for pgsql-hackers@postgresql.org; Thu, 20 Mar 2025 19:52:50 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-2235189adaeso24115735ad.0 for ; Thu, 20 Mar 2025 12:52:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1742500368; x=1743105168; darn=postgresql.org; h=user-agent: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=eEBWM0z2a/WcWu4EYeqB9pIWZRgFHo8Kx2Nm9kMSUxk=; b=A7DFhS2F+byJqwXGydzo8eBrXJmYnCnTsGDk2ENtBl9qvbVo46sHxCaVGZOycYZy7F 5cnzGbo+sZjFxApGxkOnA/cIVl42gk2WREKatA16FIgCqsEAhfNPTffJ0x4AicAiP+Pt 7pyAxFYDZFyXAROYJK3wY1LbTyYhHVRdp9NE8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742500368; x=1743105168; h=user-agent: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=eEBWM0z2a/WcWu4EYeqB9pIWZRgFHo8Kx2Nm9kMSUxk=; b=q2PzGEOUk89MMDiXBkq8OaCgI3cuA1peMBHVk5XgpL9SQAr1LiWUNEz+1zJ5dcCsvT KNfiBzxZ5bdwkIuFNZJN0ixNcbl4/uApAbIIxF/+E9u49DHfr/KWHQELpvDJqxmSRVEd ksIo87GrmX1jMp2//P7DjzNqXIpMWCmErVXb+MPk5Q4aR/YuiID+ny7FQCerRitLoEtJ sIvq7Ase74ExjqeegXhqLtV3BEpT0Dld7ZQNn2a/ewgMdmYiDoF5v7RToE0oiiOaIPkU bQXyF3+o+70ieR7drROcHi3pwvuLl+SFmMMNRG08cAgk9UGk/tpeB/2I+m4AYVaRu6qx htmQ== X-Forwarded-Encrypted: i=1; AJvYcCXxJLZf5irDq6zevlxXpxtOH74V0KhbX3ziH+Hv+NxmGMiIknufI+Oh1bpbCDiiYDv++Tla76hy/W72s+G9@postgresql.org X-Gm-Message-State: AOJu0YwuYx6RAy0T1bdizqceB9vPHaCKObtrTfL4QR+EQUVgFaLpiJ/0 tRWYEF2pFTFP8zkvtDrlPVUryBCwJRqB6xa8BL9yVgNRG1ub9sR2FS5JjqrQvQ== X-Gm-Gg: ASbGnctOwd5rkmyfMltq+U7bbDV//RPk2GziB2PaS4GvfAe8T0izt3Lv5iC2hCJm+OR HRjDZB8PzS2xglAabmcZOn6W0jGe2PWa6udNLcKL/qHb6uZxsDP6AIdOMq32EW8/+WJPIJSkZoJ rqTNd3LdC1YXLG6HMZ36ZueJic9/LzNIVafBzEqkh8tb/xokH+dSjI3UL3+mplYlxICuh1W61L1 Gop22zu/J7nMuR1nxfmeZjMxlAdunGCT2jc+DXnqxMPncW/38WY1QCuDcKMlGdvw3jJRlDtWZwy Gvs5AlhwoWxZi0ylAsbQa8OMSgKAHQ8vxdm3C8ZeUA== X-Google-Smtp-Source: AGHT+IFfywkF7yDWZQYL7wswQJ6rrl5UlDr6FIDF2RplWu9A3Q9QI1FlD2cvHDMw+ljXvcZy3w8UTQ== X-Received: by 2002:a17:902:c949:b0:21f:2e:4e4e with SMTP id d9443c01a7336-2278067c0a6mr10628295ad.5.1742500368173; Thu, 20 Mar 2025 12:52:48 -0700 (PDT) Received: from google.com ([2601:647:5600:80d0::31cd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22780f45949sm1981565ad.63.2025.03.20.12.52.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Mar 2025 12:52:47 -0700 (PDT) Date: Thu, 20 Mar 2025 12:52:45 -0700 From: Noah Misch To: Andres Freund Cc: Antonin Houska , pgsql-hackers@postgresql.org, Thomas Munro , Heikki Linnakangas , Robert Haas , Jakub Wartak , Jelte Fennema-Nio Subject: Re: AIO v2.5 Message-ID: <20250320195245.b5.nmisch@google.com> References: <4b3f32ug3cayekysqlgspz2qjmeb7lca3gvazayglxr2m3d4dv@il33accgsji7> <17906.1741863183@localhost> <3yxd5r23zly5bytvgyktbxtxq2r3gbpi7xd4dugevh3h4w4q6c@lu6oatjjpltz> <20250319212530.80.nmisch@google.com> <20250320011118.8d.nmisch@google.com> <7co5jtx2jkvpg5pde7f5wyub6w6zptfw4sbuj4n5j4iedj5zlg@u3mzxsgopnhl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7co5jtx2jkvpg5pde7f5wyub6w6zptfw4sbuj4n5j4iedj5zlg@u3mzxsgopnhl> User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Mar 20, 2025 at 02:54:14PM -0400, Andres Freund wrote: > On 2025-03-19 18:11:18 -0700, Noah Misch wrote: > > On Wed, Mar 19, 2025 at 06:17:37PM -0400, Andres Freund wrote: > > > On 2025-03-19 14:25:30 -0700, Noah Misch wrote: > > > > I see this relies on md_readv_complete having converted "result" to blocks. > > > > Was there some win from doing that as opposed to doing the division here? > > > > Division here ("blocks_read = prior_result.result / BLCKSZ") would feel easier > > > > to follow, to me. > > > > > > It seemed like that would be wrong layering - what if we had an smgr that > > > could store data in a compressed format? The raw read would be of a smaller > > > size. The smgr API deals in BlockNumbers, only the md.c layer should know > > > about bytes. > > > > I hadn't thought of that. That's a good reason. > > I thought that was better documented, but alas, it wasn't. How about updating > the documentation of smgrstartreadv to the following: > > /* > * smgrstartreadv() -- asynchronous version of smgrreadv() > * > * This starts an asynchronous readv IO using the IO handle `ioh`. Other than > * `ioh` all parameters are the same as smgrreadv(). > * > * Completion callbacks above smgr will be passed the result as the number of > * successfully read blocks if the read [partially] succeeds. This maintains > * the abstraction that smgr operates on the level of blocks, rather than > * bytes. > */ That's good. Possibly add "(Buffers for blocks not successfully read might bear unspecified modifications, up to the full nblocks.)" In a bit of over-thinking this, I wondered if shared_buffer_readv_complete would be better named shared_buffer_smgrreadv_complete, to emphasize the smgrreadv semantics. PGAIO_HCB_SHARED_BUFFER_READV likewise. But I tend to think not. smgrreadv() has no "result" concept, so the symmetry is limited. > I briefly had a bug in test_aio's injection point that lead to *increasing* > the number of bytes successfully read. That triggered an assertion failure in > bufmgr.c, but not closer to the problem. Is it worth adding an assert against > that to md_readv_complete? Can't quite decide. I'd lean yes, if in doubt.