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

Heapster Rust layout optimization for option-like types #1627

Merged
merged 6 commits into from
Apr 15, 2022

Conversation

eddywestbrook
Copy link
Contributor

This PR changes Heapster's Rust layout engine to handle the option-like type optimization of Rust.

An "option-like" type in Rust is a non-recursive enum with two variants, one of which is empty and one of which is not. The canonical example is Option<T>. The field type of the non-empty variant is called the "payload". If the payload of an option-like type has illegal values, called "niches", then Rust optimizes the layout of the option-like type so that the empty variant is represented as a value in one of these niches. So, for example, Option<&T> is laid out like a &T but where the null pointer (which is an invalid reference) represents the None constructor, while Option<T> when T is itself an enum with N constructors is laid out as T but with an extra N+1th constructor for `None.

This PR also adds a test case, the list64_tail function in rust_data.rs, to test out this option-like type optimization.

@eddywestbrook eddywestbrook added the subsystem: heapster Issues specifically related to memory verification using Heapster label Apr 14, 2022
Copy link
Member

@ChrisEPhifer ChrisEPhifer left a comment

Choose a reason for hiding this comment

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

Looks good to me; glad to have real support for this layout optimization in Heapster now!

@eddywestbrook eddywestbrook added the PR: ready to merge Magic flag for pull requests to ask Mergify to merge given an approval and a successful CI run label Apr 14, 2022
@mergify mergify bot merged commit 10fbb84 into master Apr 15, 2022
@mergify mergify bot deleted the heapster/rust-option-optimization branch April 15, 2022 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: ready to merge Magic flag for pull requests to ask Mergify to merge given an approval and a successful CI run subsystem: heapster Issues specifically related to memory verification using Heapster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants