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

Oxidation #656

Closed
wants to merge 4 commits into from
Closed

Oxidation #656

wants to merge 4 commits into from

Conversation

cgwalters
Copy link
Member

@cgwalters cgwalters commented Jan 26, 2017

This is an initial drop of "oxidation", or adding implementation
of components in Rust. The bupsplit code is a good target - no
dependencies, just computation.

Translation into Rust had a few twists -

  • The C code relies a lot on overflowing unsigned ints, and
    also on the C promotion rules for e.g. uint8_t -> int32_t
  • There were some odd loops that I introduced bugs in while
    translating...in particular, the function always returns len,
    but I mistakenly translated to len+1, resulting in an OOB
    read on the C side, which was hard to debug.

On the plus side, an off-by-one array indexing in the Rust code paniced nicely.

In practice, we'll need a lot more build infrastructure to make this work, such
as using cargo vendor when producing build artifacts for example. Also, Cargo
is yet another thing we need to cache.

Where do we go with this? Well, I think we should merge this, it's not a lot of
code. We can just have it be an alternative CI target. Should we do a lot more
right now? Probably not immediately, but I find the medium/long term prospects
pretty exciting!

@cgwalters
Copy link
Member Author

Depends on #655

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

Can you rebase this on the latest master?

Makefile.am Outdated
endif

check-local:
cd $(srcdir)/rust && CARGO_TARGET_DIR=@abs_top_builddir@/target cargo test
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually need this target? Or are we planning to use the rust testing framework as well? Might want to rename it to rust-check or similar.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we'd definitely use the Rust unit testing framework, it's really nice. In this case I explicitly chose not to because the idea is we could reuse the exact same tests that were done for the C implementation.

This is an initial drop of "oxidation", or adding implementation
of components in Rust.  The bupsplit code is a good target - no
dependencies, just computation.

Translation into Rust had a few twists -

 - The C code relies a lot on overflowing unsigned ints, and
   also on the C promotion rules for e.g. `uint8_t -> int32_t`
 - There were some odd loops that I introduced bugs in while
   translating...in particular, the function always returns `len`,
   but I mistakenly translated to `len+1`, resulting in an OOB
   read on the C side, which was hard to debug.

On the plus side, an off-by-one array indexing in the Rust code paniced nicely.

In practice, we'll need a lot more build infrastructure to make this work, such
as using `cargo vendor` when producing build artifacts for example. Also, Cargo
is yet another thing we need to cache.

Where do we go with this? Well, I think we should merge this, it's not a lot of
code. We can just have it be an alternative CI target. Should we do a lot more
right now? Probably not immediately, but I find the medium/long term prospects
pretty exciting!
@cgwalters
Copy link
Member Author

🏄

@jlebon
Copy link
Member

jlebon commented Feb 3, 2017

OK cool. I won't pretend to understand all of the Rust code itself, but the integration itself looks nice!
@rh-atomic-bot r+ 5d51c7c

@rh-atomic-bot
Copy link

⌛ Testing commit 5d51c7c with merge d894f60...

@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: jlebon
Pushing d894f60 to master...

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.

None yet

3 participants