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 1stBRw-00EBt3-UI for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Sep 2024 19:43:53 +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 1stBRw-00D0vp-9j for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Sep 2024 19:43:52 +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 1stBRv-00D0vh-MP for pgsql-hackers@lists.postgresql.org; Tue, 24 Sep 2024 19:43:52 +0000 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1stBRn-000tM4-JY for pgsql-hackers@postgresql.org; Tue, 24 Sep 2024 19:43:50 +0000 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-277f0540c3aso3111372fac.3 for ; Tue, 24 Sep 2024 12:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1727207023; x=1727811823; 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=6Iavdzc7PD+HHC8P+ww5KihCtZpIOhrLceUbGpaSQS8=; b=e08kX0x80Lg+K3ZKvNOG/d4xbG8DxJMvd4XWc/EHBkGtws6PkOm6uITZxFAYkv3BBO TqOZLX4EdvheD+hqOAG9+MBF1bPz+lzQeXcUYp+ZNCbSnjUhxAFVKD2T4t0xaodydPkc tbxv130C3dXF41hukuq+Z29o8gFeM5xlrOPdw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727207023; x=1727811823; 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=6Iavdzc7PD+HHC8P+ww5KihCtZpIOhrLceUbGpaSQS8=; b=sP9Xq7Sui7gUZ8zixVeNaELccD+DhGOuLmM9cTMwa17iR764OtrPbYpxRcoOTTYJB3 OjZU/lkHhzx4preaIeuGOSTpATsasHDxaVDu4VsHlwlmUbLEU9VujNaIPwCGJG5BqIme Avm2egJ4z7lP5kReiUh/iLSdLscddmZRek0A++Ry8lMnC3n3UrSPLEthpV9VV2q+ViCZ VUE3hevKHJnxxb85NBZsMQm4cfOpYQj2yhNY9itrR5jKCWz/lcDewBOoTRP/V/UyOBnd kYSDcKTIkrFSrKZ9zd6SLPH/q4MPaOqAYDTTQxcMiO/PgotzKFJt39aNia92l9GZ7Qs7 3jXA== X-Gm-Message-State: AOJu0YzRQcOYsf/1A8JTDmntrOhCmaFkSrV+NLG4YVyUzUgYYzyvP8pm 0TU+1PTLp/7lmiWaAWUGcvm/1FyYYyN9RcbrqH+y7O6gU158ok+EF8OERw57LQ== X-Google-Smtp-Source: AGHT+IFSmRg4Sg7r6m+H/8LlRh1EEzg2F44eBGGYjTqd+GBbyJqtZpNzobbDpQ6uyQM5Ogx90fyWwA== X-Received: by 2002:a05:6870:a50e:b0:261:16da:decb with SMTP id 586e51a60fabf-286e1354866mr642045fac.11.1727207023347; Tue, 24 Sep 2024 12:43:43 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-713beaf363fsm573719a34.35.2024.09.24.12.43.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Sep 2024 12:43:42 -0700 (PDT) Date: Tue, 24 Sep 2024 12:43:40 -0700 From: Noah Misch To: Andres Freund Cc: pgsql-hackers@postgresql.org, Heikki Linnakangas , Robert Haas , Thomas Munro Subject: Re: AIO writes vs hint bits vs checksums Message-ID: <20240924194340.92.nmisch@google.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Tue, Sep 24, 2024 at 11:55:08AM -0400, Andres Freund wrote: > So far the AIO patchset has solved this by introducing a set of "bounce > buffers", which can be acquired and used as the source/target of IO when doing > it in-place into shared buffers isn't viable. > > I am worried about that solution however, as either acquisition of bounce > buffers becomes a performance issue (that's how I did it at first, it was hard > to avoid regressions) or we reserve bounce buffers for each backend, in which > case the memory overhead for instances with relatively small amount of > shared_buffers and/or many connections can be significant. > But: We can address this and improve performance over the status quo! Today we > determine tuple visiblity determination one-by-one, even when checking the > visibility of an entire page worth of tuples. That's not exactly free. I've > prototyped checking visibility of an entire page of tuples at once and it > indeed speeds up visibility checks substantially (in some cases seqscans are > over 20% faster!). Nice! It sounds like you refactored the relationship between heap_prepare_pagescan() and HeapTupleSatisfiesVisibility() to move the hint bit setting upward or the iterate-over-tuples downward. Is that about right? > Once we have page-level visibility checks we can get the right to set hint > bits once for an entire page instead of doing it for every tuple - with that > in place the "new approach" of setting hint bits only with BM_SETTING_HINTS > wins. How did page-level+BM_SETTING_HINTS performance compare to performance of the page-level change w/o the BM_SETTING_HINTS change? > Having a page level approach to setting hint bits has other advantages: > > E.g. today, with wal_log_hints, we'll log hint bits on the first hint bit set > on the page and we don't mark a page dirty on hot standby. Which often will > result in hint bits notpersistently set on replicas until the page is frozen. Nice way to improve that. > Does this sound like a reasonable idea? Counterpoints? I guess the main part left to discuss is index scans or other scan types where we'd either not do page-level visibility or we'd do page-level visibility including tuples we wouldn't otherwise use. BM_SETTING_HINTS likely won't show up so readily in index scan profiles, but the cost is still there. How should we think about comparing the distributed cost of the buffer header manipulations during index scans vs. the costs of bounce buffers? Thanks, nm