[pbs-devel] [PATCH v2 proxmox-backup 2/3] debug cli: add 'compare-content' flag to `diff archive` command
Wolfgang Bumiller
w.bumiller at proxmox.com
Tue Dec 6 16:01:26 CET 2022
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()...
More information about the pbs-devel
mailing list