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 1tEb8e-008T9k-Po for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Nov 2024 21:24:29 +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 1tEb8c-00ChLQ-Sc for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Nov 2024 21:24:26 +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 1tEb8c-00ChGW-Ef for pgsql-hackers@lists.postgresql.org; Fri, 22 Nov 2024 21:24:26 +0000 Received: from lahtoruutu.iki.fi ([2a0b:5c81:1c1::37]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tEb8Y-003HEC-Dc for pgsql-hackers@lists.postgresql.org; Fri, 22 Nov 2024 21:24:25 +0000 Received: from [192.168.1.110] (dsl-hkibng22-50ddb7-241.dhcp.inet.fi [80.221.183.241]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4Xw7QS4h2Fz49Q8v; Fri, 22 Nov 2024 23:24:16 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1732310657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EkNxyLXv7pq6Rlga1QdvYcfevjQQNvZA3HB3bolXd2A=; b=ntuMlccQsOJMA9x/AG8NH6Z2soIPh8KkzwxpdmFn9C/t2CwLYHwucW0T6lGyxWTz9m577y cJU1IfepE7mJF8prxxbpWPxMgKIIQHKDsr8gCyBakhxUu2fQForAsD483jaaNg1aISK9pr HuxMJMPmZhcY0rdxl6WGK+jQh+kC9rniKwAnTArytLw91S58/RkOgH2ZFN+/RGjFW3PgEz N9i6qvjbp8J/0L3N5n9aOlSuFfJLMeB1mpx3tj1CvhqA0akXKU7NfRaghlQP4nLb41IWpP Nxpx6A4ja7VYwsKZT+aP37qQvRFVRPYRA6EsbsNrT6MYWfy9KvwcE6BSSyLZJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1732310657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EkNxyLXv7pq6Rlga1QdvYcfevjQQNvZA3HB3bolXd2A=; b=FdF2X8jMmoyCqCr21uvUPta0oLfx8HwThILZQZXulhSAwPIBp85fymVe1qsp1vWk6rHHp9 hZNC06F02qKpSqFkdFMJX+2DN9NSGZFTEFmuuJjvKlmIdhx2Wcj2KtbaSEsvuPbdr7GgCD vEoIoADmOjttlkhguhPi51G6ketvImygBG+HeiKP/r1MhpK0n69BtvujMmfbvSquUDIP72 j0QjPRFSc/inaoT4ufeGMc2uXCBGrKFM0VhwuAv7JlPs6OKC7tKrmNCkoqFDCeEHpxt3NP oZGKnSJrNglQhpTjv8MEaVjK2uzOzhmtXFutcPeXTOV+2D3ZWCCKRbAl2gdBCQ== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1732310657; a=rsa-sha256; cv=none; b=ghhpf7hvEhLfvXxurI5MZKR1dFCXcKieiRvhK49J5zTVA2GhfItMfuDDdfl5G/+PlACfTM 63I+4ljLJ6o97hrJx0EtB9baJQLZEo1duiOrVdtalMacYr8psn/kCkP3k9cGVBS9a7kez0 ZSU7fsF3f/6oRxo6Cc2hRhHTdAP+2zhZbqfITfbKLfk69SSODzMXQjv8ZtLPbAf5fBCvDr n+apqIl+KvJ5NS4Hlj4fc45XE3T+4zSV1lP4bNsvuMVKDG02x8cyCOFi0itHjQYQXAo5Lt B9/HslaSgBFoY3K/SwZbU0TJ0fD3C4kJxdY9erYo9FuHzxKI54ivoWaemyCjzg== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi Message-ID: <5544a0e0-1341-477a-83cd-c616cd016388@iki.fi> Date: Fri, 22 Nov 2024 23:24:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: smgrextendv and vectorizing the bulk_write implementation To: Matthias van de Meent , PostgreSQL Hackers Cc: Thomas Munro References: Content-Language: en-US From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 22/11/2024 19:49, Matthias van de Meent wrote: > Hi, > > While working on the fix for [0] I noticed that bulk_write doens't use > any of the new vectorized IO features, which seemed like a waste. > After looking into it a bit deeper, I noticed the opportunity for > write vectorization was not very high, as one would expect most > bulk_write IOs to be smgrextend(), which only does page-sized writes. > That's something that can be solved, though, and so I started this > patch. +1 > I've attached two patches to address these two items: > > Patch 1/2 reworks smgrextend to smgrextendv, which does mostly the > same stuff as the current smgrextend, but operates on multiple pages. > Patch 2/2 updates bulk_write to make use of smgrwritev, > smgrzeroextend, and the new smgrextendv API, thus reducing the syscall > burden in processes that use bulk extend APIs. Seems straightforward. Thomas wrote patches earlier to do similar thing, see https://www.postgresql.org/message-id/CA%2BhUKGLx5bLwezZKAYB2O_qHj%3Dov10RpgRVY7e8TSJVE74oVjg%40mail.gmail.com. I haven't looked closely at the patches to see what the differences are. > Open question: > In my version of smgrextendv, I reject any failure to extend by the > requested size. This is different from smgrwrite, which tries to write > again when FileWriteV returns a short write. Should smgrextendv do > retries, too? Hmm, a short write seems just as possible in smgrextendv() too, it should retry. In principle you could get a short write even with a BLCKSZ write. We've always just assumed that it won't happen, or if it does it means you ran out of disk space. I don't know why we ever assumed that, even though it has worked in practice. But I think we should stop assuming that going forward, and always retry short writes. -- Heikki Linnakangas Neon (https://neon.tech)