public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>
Cc: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,
	 Dominik Csapak <d.csapak@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox 1/2] add tools/zero: add fast zero comparison code
Date: Mon, 14 Dec 2020 13:52:52 +0100	[thread overview]
Message-ID: <20201214125252.py4shrxos24zrpqs@wobu-vie.proxmox.com> (raw)
In-Reply-To: <beca62bb-2a0a-8317-61ec-cc165b96d390@proxmox.com>

Some testing & internal talk led to the decision to exclude this patch.

apart from being incomplete (some alignment issues aren't handled),
rustc itself is very capable of producing fast SSE code for this, if you
know *how*:

Assuming an `fn is_zero(buf: &[u8]) -> bool`:

a) `buf.contains(&0)`

    compiles to a naive loop, slow

b) `buf.iter().fold(0, |a, b| a | b) == 0`

    produces fast SSE code loading 128 bytes at a time (sort of) into
    xmm registers, (pretty much the code from this commit, but better),

    however, this doesn't stop at the first non-zero

c) ```
   buf
       .chunks(128)
       .map(|aa| aa.iter().fold(0, |a, b| a|b) != 0)
       .any(|a| a)
   ```

    A compromise suggested by Fabian G.
    Much like case (b), the inner loop loads 128 bytes directly via sse
    instructions, but we also have the outer chunks to stop early

On Mon, Dec 14, 2020 at 09:38:49AM +0100, Thomas Lamprecht wrote:
> On 11.12.20 13:08, Dominik Csapak wrote:
> > that can make use of see/avx instructions where available
> > 
> 
> maybe some performance numbers can help to argue why we should add
> that, maybe directly as small benchmark binary so different CPUs
> could be compared?
> 
> > this is mostly a direct translation of qemu's util/bufferiszero.c
> > 
> > this is originally from Wolfgang Bumiller
> 
> FYI, you could use the
> 
> Originally-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
> 
> git trailer for that, I saw it a few times used in other projects (e.g.,
> kernel)




  reply	other threads:[~2020-12-14 12:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 12:08 [pbs-devel] [PATCH RFC proxmox/proxmox-backup] restore files from pxar sparsely Dominik Csapak
2020-12-11 12:08 ` [pbs-devel] [PATCH proxmox 1/2] add tools/zero: add fast zero comparison code Dominik Csapak
2020-12-14  8:38   ` Thomas Lamprecht
2020-12-14 12:52     ` Wolfgang Bumiller [this message]
2020-12-11 12:08 ` [pbs-devel] [PATCH proxmox 2/2] proxmox: add sparse_copy(_async) to tools::io Dominik Csapak
2020-12-11 12:08 ` [pbs-devel] [PATCH proxmox-backup 1/1] pxar/extrac: if possible create files sparesly Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201214125252.py4shrxos24zrpqs@wobu-vie.proxmox.com \
    --to=w.bumiller@proxmox.com \
    --cc=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=t.lamprecht@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal