-
Notifications
You must be signed in to change notification settings - Fork 214
Baked data: use VarULE to store data when specified #6133
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
Conversation
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.
I think this design of sticking it on the export traits is good: it avoids cluttering core data marker infra whilst still providing extra metadata for export.
Created #6135 to reduce the diff |
This PR is passing CI and ready from my perspective. I am unclear whether the open comments are bikeshed issues or fundamental design issues, and how you hope that they be resolved. |
@sffc From my side, the trait naming is a bikeshed that can be deferred, and the macro opt-in/opt-out is a concern I'd prefer solved here but is not a major design issue. The overall design looks good. |
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.
OK to land from my end, would prefer the trait be renamed, but can happen later.
provider/core/src/varule_traits.rs
Outdated
/// Some data structs can be represented compactly as a single [`VarULE`], | ||
/// such as `str` or a packed pattern. This trait allows for data providers | ||
/// to use storage optimizations for such types. |
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.
issue: you frame this as "storage optimizations", but that's not why we're doing this.
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.
But it is?
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.
no, this is a compile time improvement, at the expense of runtime performance
I have not seen any data that this reduces storage size
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.
It is a storage optimization that reduces compile times and binary size.
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.
do you have data?
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.
I removed the word "storage". The point of this remark is that it can be used for optimizations at the discretion of the data provider.
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.
As we discussed in the WG meeting, I previously shared what I consider sufficient preliminary data in the main issue #5230, and more data can be gathered once this lands and is integrated into places such as datetime.
Co-authored-by: Robert Bastian <[email protected]>
There have been over 100 comments on this PR, all of which have been resolved, except possibly for the open question about data collection. Anything else blocking this from landing? |
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.
fine to merge for now, but I consider benchmarking this 2.0 blocking
can you post the semver diffs that this locks us in to? |
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.
Glad to see this landing!
Changed APIs:
New APIs:
|
I actually disagree with this one and have a mild preference for using a custom ZST here, but didn't think it that big a deal. ZSTs are weird and there are multiple ways one might expect a Happy to make that change if people agree. |
This has given me some confusing errors while migrating this. The place where this will fail if the macro hasn't been called is in |
What are the multiple ways one might expect The one I implemented was "Ok if the bytes are empty, Err if they are nonempty". I guess one could also implement "Always Err"? |
Yes, effectively. It's the difference between whether people plan to actually use it or just have it be a sentinel. |
My intuition is that since |
Even I don't really see a purpose for We ended up releasing this in zerovec anyway (I didn't want to further block landing this) so there's not much to do about undoing it without a breaking release. But basically: I definitely do not think this impl is "something we can/should have regardless", and in the medium term I'd like to deprecate it. |
#5230
I did it by creating a trait,
MaybeAsVarULE
, which is implemented on data structs, similar to howBake
andSerialize
are implemented on data structs.The trait has an associated type that I can leverage in the baked exporter without having to do
dyn Any
downcasting.I tried to keep my understanding of @robertbastian's position in mind while writing this PR (don't add anything hyper-specific to bake in the provider crate), and I think I achieved this, since the thing I added is on the same level as the existing format-specific traits.
See the hello world data for an example. I didn't apply it to the other data markers yet.