From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3E94167257; Tue, 12 Jan 2021 10:29:53 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2E83622474; Tue, 12 Jan 2021 10:29:23 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 1289222468; Tue, 12 Jan 2021 10:29:22 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C7A5245393; Tue, 12 Jan 2021 10:29:21 +0100 (CET) Date: Tue, 12 Jan 2021 10:29:20 +0100 From: Wolfgang Bumiller To: Stefan Reiter Cc: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com Message-ID: <20210112092920.g4hsrih5pa6uvqbq@wobu-vie.proxmox.com> References: <20210111111409.32385-1-s.reiter@proxmox.com> <20210111111409.32385-3-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210111111409.32385-3-s.reiter@proxmox.com> User-Agent: NeoMutt/20180716 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.049 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH qemu 02/11] PVE: block/pbs: fast-path reads without allocation if possible X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jan 2021 09:29:53 -0000 On Mon, Jan 11, 2021 at 12:14:00PM +0100, Stefan Reiter wrote: > ...and switch over to g_malloc/g_free while at it to align with other > QEMU code. > > Tracing shows the fast-path is taken almost all the time, though not > 100% so the slow one is still necessary. I wonder if vectored reads could be implemented directly at the library&rust code level... this would probably have to go all the way from here to the hyper request code though, since it's not really part of AsyncRead :-\ > Signed-off-by: Stefan Reiter > --- > > For that slight unnoticable performance boost :) > > block/pbs.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/block/pbs.c b/block/pbs.c > index 1481a2bfd1..fbf0d8d845 100644 > --- a/block/pbs.c > +++ b/block/pbs.c > @@ -200,7 +200,16 @@ static coroutine_fn int pbs_co_preadv(BlockDriverState *bs, > BDRVPBSState *s = bs->opaque; > int ret; > char *pbs_error = NULL; > - uint8_t *buf = malloc(bytes); > + uint8_t *buf; > + bool inline_buf = true; > + > + /* for single-buffer IO vectors we can fast-path the write directly to it */ > + if (qiov->niov == 1 && qiov->iov->iov_len >= bytes) { > + buf = qiov->iov->iov_base; > + } else { > + inline_buf = false; > + buf = g_malloc(bytes); > + } > > ReadCallbackData rcb = { > .co = qemu_coroutine_self(), > @@ -218,8 +227,10 @@ static coroutine_fn int pbs_co_preadv(BlockDriverState *bs, > return -EIO; > } > > - qemu_iovec_from_buf(qiov, 0, buf, bytes); > - free(buf); > + if (!inline_buf) { > + qemu_iovec_from_buf(qiov, 0, buf, bytes); > + g_free(buf); > + } > > return ret; > } > -- > 2.20.1