-
Notifications
You must be signed in to change notification settings - Fork 30
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
Implementing get_size for everything #197
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Is there a way to add a test to check the sizes are actually what we expect? (Eg they match with the plugin header) |
You're right. We should probably have serialization size tests for every plugin. |
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.
Looked at the trait implementations. Still need to look at processor code.
programs/mpl-core/src/plugins/internal/authority_managed/attributes.rs
Outdated
Show resolved
Hide resolved
programs/mpl-core/src/plugins/internal/authority_managed/royalties.rs
Outdated
Show resolved
Hide resolved
programs/mpl-core/src/plugins/internal/authority_managed/verified_creators.rs
Outdated
Show resolved
Hide resolved
programs/mpl-core/src/plugins/mod.rs
Outdated
@@ -88,6 +88,38 @@ impl Plugin { | |||
|
|||
impl Compressible for Plugin {} | |||
|
|||
impl DataBlob for Plugin { | |||
fn get_initial_size() -> usize { | |||
1 |
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.
is this really 1 or since there's no None
, is it each plugin's initial size?
1 + match self {
Plugin::Royalties(royalties) => royalties.get_initial_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.
There's still one byte required for the plugin enum discriminator.
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.
Right but there's no default value that is only the descriminator, so there's no time you could ever use BASE_LEN
and it would be correct, right?
Whereas for example Attribute
, the BASE_LEN
would be the length of an empty key/value pair and you could call it for a default value.
I can't think of a good solution for this except for adding a None
variant, which is a contrived solution as there's not an actual reason to add it
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.
Ah yeah I see what you mean. Maybe BASE_LEN should be private or not required?
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 like that idea of not having BASE_LEN
as a public trait const, and then people should only ever use len()
which would work for empty or non-empty items. Like len() should always be trustable.
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's a little annoying when we have multi-level data blobs, still. Because with no public BASE_LEN you need to hard code the underlying type's 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.
Looks good but I agree with both of you we should add that testing now.
…dation/mpl-core into feat/impl-get-size
This reverts commit 84758e9.
…foundation/mpl-core into feat/impl-get-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.
Benchmark
Benchmark suite | Current: 33b5220 | Previous: 87e2e35 | Ratio |
---|---|---|---|
CU: create a new, empty asset |
11182 Compute Units |
11082 Compute Units |
1.01 |
Space: create a new, empty asset |
91 Bytes |
91 Bytes |
1 |
CU: create a new, empty asset with empty collection |
22655 Compute Units |
22555 Compute Units |
1.00 |
Space: create a new, empty asset with empty collection |
91 Bytes |
91 Bytes |
1 |
CU: create a new asset with plugins |
35091 Compute Units |
40123 Compute Units |
0.87 |
Space: create a new asset with plugins |
194 Bytes |
194 Bytes |
1 |
CU: create a new asset with plugins and empty collection |
41167 Compute Units |
46145 Compute Units |
0.89 |
Space: create a new asset with plugins and empty collection |
194 Bytes |
194 Bytes |
1 |
CU: list an asset |
28041 Compute Units |
30237 Compute Units |
0.93 |
CU: sell an asset |
39312 Compute Units |
38699 Compute Units |
1.02 |
CU: list an asset with empty collection |
35599 Compute Units |
37795 Compute Units |
0.94 |
CU: sell an asset with empty collection |
51640 Compute Units |
51027 Compute Units |
1.01 |
CU: list an asset with collection royalties |
36336 Compute Units |
38499 Compute Units |
0.94 |
CU: sell an asset with collection royalties |
56565 Compute Units |
55952 Compute Units |
1.01 |
CU: transfer an empty asset |
6420 Compute Units |
6320 Compute Units |
1.02 |
CU: transfer an empty asset with empty collection |
9018 Compute Units |
8918 Compute Units |
1.01 |
CU: transfer an asset with plugins |
14719 Compute Units |
14604 Compute Units |
1.01 |
CU: transfer an asset with plugins and empty collection |
17317 Compute Units |
17202 Compute Units |
1.01 |
This comment was automatically generated by workflow using github-action-benchmark.
…into feat/impl-get-size
programs/mpl-core/src/plugins/internal/owner_managed/burn_delegate.rs
Outdated
Show resolved
Hide resolved
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.
Overall looks great and love the testing, but I have one nagging concern about BASE_LEN
(see comments)
Fully implementing get_size and switching to that over serialized data size.