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

Add serialization capabilities to RequiredResources #1893

Merged
merged 7 commits into from
Jul 9, 2021

Conversation

danobi
Copy link
Member

@danobi danobi commented Jun 22, 2021

This PR enables RequiredResources to be serialized to disk and
then later deserialized back into memory.

Maintaining serialization/deserialization is a tad invasive and it will
require constant vigilance when new fields are added. Fortunately,
it's not too many types and other types of changes (renames, type
changes) should be caught by the compiler. Hopefully it's not too
much of a bother.

Note that this change also adds a new required dependency:
libcereal. Most distros have it packaged: https://pkgs.org/search/?q=cereal .

cereal was chosen over libnop b/c cereal seems more widely
used and popular and is also packaged in more distros.

Checklist
  • Language changes are updated in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

@danobi danobi force-pushed the serialize branch 4 times, most recently from 6400379 to 4da5515 Compare June 22, 2021 17:38
@danobi danobi marked this pull request as ready for review June 22, 2021 18:31
CHANGELOG.md Outdated Show resolved Hide resolved
danobi added 2 commits July 8, 2021 11:49
cereal ( https://uscilab.github.io/cereal/ ) was chosen because of its
active community, battle-tested-ness, and the fact that it's packaged on
every distro known to package bpftrace (I think).
danobi added 5 commits July 8, 2021 15:16
cereal cannot serialize raw pointers (see
https://uscilab.github.io/cereal/pointers.html). As a compromise, use an
std::weak_ptr instead of a raw pointer. std::weak_ptr has similar
semantics to a raw pointer.
This commit adds `RequiredResources` serialization support. In other
words, we add routines to allow `RequiredResources` to be stored to disk
and reloaded back into memory.

This is a crucial building block for AOT support as we will need to be
able to transport script metadata around.

Note that the serialization changes are a bit invasive and will require
constant vigilance in the event that any new fields are added. cereal's
type system should be able to catch any renaming or type changes, albeit
with a rather cryptic compile error.
Copy link
Member

@fbs fbs 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, will be interesting to see the final aot construct

@danobi danobi merged commit 15e5a05 into bpftrace:master Jul 9, 2021
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.

2 participants