Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Default requirement on ByteValued #274

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

Ablu
Copy link
Contributor

@Ablu Ablu commented Dec 6, 2023

Since zeros are a valid value for any ByteValued type, we can use that instead of relying on a Default implementation (which may not be auto-derivable for some array types).

Further optimizations would be possible if we would have access to a pointer value into the source data. Then we could also use ptr::copy_nonoverlapping and avoid pre-initialization altogether. But changing the API just for that seems a bit excessive.

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR are signed (with git commit -s), and the commit
    message has max 60 characters for the summary and max 75 characters for each
    description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

Copy link
Collaborator

@roypat roypat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this makes sense to me, I've thought about it before. Maybe, given that there's been issues with implementing this trait, and we have #246, long term it might make sense for us to just use the zerocopy crate in vm-memory, to replace ByteValued 🤔 Although one would have to check if it can deal with volatile memory

Since zeros are a valid value for any ByteValued type, we can use
that instead of relying on a Default implementation (which may not be
auto-derivable for some array types).

Further optimizations would be possible if we would have access
to a pointer value into the source data. Then we could also use
ptr::copy_nonoverlapping and avoid pre-initialization altogether. But
changing the API just for that seems a bit excessive.

Signed-off-by: Erik Schilling <[email protected]>
@roypat roypat merged commit 447d945 into rust-vmm:main Dec 14, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants