From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Lukas Wagner <l.wagner@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: Re: [pbs-devel] [PATCH v2 proxmox-backup 2/3] debug cli: add 'compare-content' flag to `diff archive` command
Date: Tue, 6 Dec 2022 16:01:26 +0100 [thread overview]
Message-ID: <20221206150126.5gjsx5hn6blzxwo7@casey.proxmox.com> (raw)
In-Reply-To: <41086f37-8fea-8cda-ae90-1c152ef4b047@proxmox.com>
On Tue, Dec 06, 2022 at 03:44:07PM +0100, Lukas Wagner wrote:
> Hi,
>
> On 12/6/22 12:39, Wolfgang Bumiller wrote:
> > > +{
> > > + let mut buf_a = vec![0u8; BUFFERSIZE];
> > > + let mut buf_b = vec![0u8; BUFFERSIZE];
> >
> > Maybe use a Box instead of a Vec, we don't ever resize this atm.
> >
>
> Do you mean like this?
> let mut buf_a = Box::new([0u8; BUFFERSIZE]);
>
> AFAIU this would construct the array on the stack first before it is moved into the Box,
> leading to some unnecessary memcpys. Or am I missing something here?
With these sizes - and this is only on the CLI AFAICT - this is not an
issue, and in --release builds this will be optimized out.
I prefer not to do things weirdly because "the compiler does stupid
things" if it can be avoided. (Some kind of "placement-new"-like
construct is *really* missing in rust...)
And none of `Box::new_zeroed*`, `Box::new_uninit*` are stable yet, and
even if they were, there's no ergonomic POD version that doesn't imply a
`MaybeUninit`.
Perhaps we should start a proxmox_bytes crate where we move
proxmox_io::vec to, and add a box module for box::zeroed() and
box::uninit()...
next prev parent reply other threads:[~2022-12-06 15:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-05 14:55 [pbs-devel] [PATCH v2 proxmox-backup 0/3] debug cli: improve output, optionally compare file content for `diff archive` Lukas Wagner
2022-12-05 14:55 ` [pbs-devel] [PATCH v2 proxmox-backup 1/3] debug cli: show more file attributes for `diff archive` command Lukas Wagner
2022-12-05 14:55 ` [pbs-devel] [PATCH v2 proxmox-backup 2/3] debug cli: add 'compare-content' flag to " Lukas Wagner
2022-12-06 11:39 ` Wolfgang Bumiller
2022-12-06 14:44 ` Lukas Wagner
2022-12-06 15:01 ` Wolfgang Bumiller [this message]
2022-12-05 14:55 ` [pbs-devel] [PATCH v2 proxmox-backup 3/3] debug cli: add colored output " Lukas Wagner
2022-12-06 11:49 ` Wolfgang Bumiller
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=20221206150126.5gjsx5hn6blzxwo7@casey.proxmox.com \
--to=w.bumiller@proxmox.com \
--cc=l.wagner@proxmox.com \
--cc=pbs-devel@lists.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.