-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
[internal] Store Value
s and DirectoryDigest
s as boxed references in the workunit store.
#14749
Conversation
…ues and DirectoryDigests. [ci skip-build-wheels]
93f3090
to
b8ba625
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably worth some more comments in the code about why we use Any
, such as on the as_any
methods
pub enum UserMetadataItem { | ||
PyValue(UserMetadataPyValue), | ||
// NB: Always stores a ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, yep.
As to your other comment: the traits try to explain themselves:
// NB: Only implemented for `Value`, but is boxed to avoid a cycle between this crate and the
// `engine` crate.
... as does the as_any
method:
// See https://vorner.github.io/2020/08/02/fights-with-downcasting.html.
fn as_any(&self) -> &dyn Any;
# Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
// is only as large as its pointers. | ||
known_deep_size!(8 * 3; Value); | ||
// is only as large as its pointer. | ||
known_deep_size!(8; Value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of assuming the size is 8, maybe use std::mem::size_of<* cosnt ()>
or some other pointer type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mm, yea: good idea. I think that I wasn't sure whether it would work with the macro.
To avoid cycles between the
workunit_store
crate and theengine
andfs
crates,UserMetadataItem::PyValue
andArtifactOutput::Snapshot
both used indirection.But in #14723,
ArtifactOutput::Snapshot
storing ahashing::Digest
will no longer be a sufficient replacement for storing afs::DirectoryDigest
, because we no longer guarantee that all (directory)Digest
s have actually been persisted to disk: some of them exist only in memory asDigestTrie
s held byDirectoryDigest
s. And we don't want to introduce a cycle betweenfs
and theworkunit_store
crate.To fix both cases, we use a
Box
edAny
(technically,Arc
ed, since we needClone
), and downcast to the underlying type at the consume side.