-
Notifications
You must be signed in to change notification settings - Fork 312
Implementation of the custom descriptors proposal #2295
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
Implementation of the custom descriptors proposal #2295
Conversation
alexcrichton
left a comment
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 only skimmed the validation/bit-packing-RefType bits and I'll cc @fitzgen for those bits too as I'm sure he'll be interested in them when they shape up. Otherwise I left a few comments here and there. Overall thanks for this though!
07068fa to
0b11138
Compare
fitzgen
left a comment
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.
Thanks!
9763983 to
9d29633
Compare
fitzgen
left a comment
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.
Changing RefType to 4 bytes is going to make ValType larger than 4 bytes, which has been observed to have been a pretty big slow down in part work. I'm going to try and avoid that via
- Allowing
ValTypeto remain a nice Rustenumand grow larger than 4 bytes, but then - Creating an internal
ValTypePackedtype that is still 4 bytes but is not a niceenumand has worse ergonomics - Making the core validation loop use
ValTypePackedinstead ofValType
This should relieve the pressure you're bumping up against. I'll whip this up and then once it has landed on main you can rebase and then this should be able to merge (modulo any other review comments Alex might have, I haven't looked at anything other than the RefType bitpacking stuff).
Thanks for your patience @yurydelendik!
I was hoping I would finish this up before the weekend but it looks like I won't. Since the CG meeting in Munich is next week, I probably won't finish this until the week afterwards. |
|
Draft PR here: #2369 Alex has ideas about landing this PR before that, though. |
|
Ok I've done a bit of benchmarking now. With this PR as-is: bench resultsSo not obviously bad. It's actually a speedup on all 'real world' modules but is an equivalent regression on synthetic stressor modules. Next I took #2369 and massaged it into the validator as well. The commit is alexcrichton@c2d95e4 and is pretty messy as my goal was just to get to the point of benchmarking. Try as I might it's a net regression across the board: bench numbersI've tried a number of ways to further optimize this in my commit, but to no avail. In retrospect this makes sense though:
So my conclusion is that we should land this PR as-is. Update the test to accept an 8-byte |
Yeah I was hoping that the conversions would pretty much get inlined away and it is unfortunate that you aren't seeing that. I think I agree with your conclusion that we can land this PR as-is (modulo CI going green) but I think it is worth thinking a tiny bit more about |
FWIW, I think we should care about the real world modules way more than the synthetic ones. |
More-or-less this is what I saw. For example, this is one of the hottest methods in the validator: fn visit_local_set(&mut self, local_index: u32) -> Self::Output {
let ty = self.local(local_index)?;
self.pop_operand(Some(ty))?;
self.local_inits.set_init(local_index);
Ok(())
}Here We could fix this by changing |
Yeah, makes sense to me. Really wish Rust didn't make us choose between packing and ergonomics! |
|
@yurydelendik alright if you're ok with it the ball's now back in your court. I pushed up two commits here (feel free to rebase/squash them away as you see fit) as well as a merge with |
Also adjust the validation of `Exact` feature-wise and add a test that custom-descriptors constructs are rejected without the feature.
8524917 to
5182421
Compare
Thanks. I rebased and adjusted most of syntax. Changed logic around ref.get_desc and ref.cast_desc too. Not implement is parsing of some 'exact' case, e.g. in imports -- that requires some deep diving into data structures. Will be looking at that next |
|
Happy to help out if you get stuck! I just pushed up a commit which is a re- |
|
Also, if you'd like, these tests are pretty minor so I think it would be reasonable to land what you have here and address the missing functionality in a follow-up too. Whichever you'd prefer. |
That sounds good. We can land what is here so far, at any moment. I'll continue working on exact types in imports. |
|
Ok sounds good, I'll do one final pass on review and frob CI to get the test to be expected to fail and then land this |
Draft implementation of the proposal that can be found at https://github.com/WebAssembly/custom-descriptors/blob/main/proposals/custom-descriptors/Overview.md.
Keeping it as draft:
PackedIndexorRefTypemask extension for exact type is okayref.funcThere are no tests or valid examples in the proposal yet: providing my own.