Skip to content

component::__internal::InstanceType now owns its contents #10616

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

Closed
wants to merge 2 commits into from

Conversation

pchickey
Copy link
Contributor

Having refs to a pair of arcs made it less expensive to create an InstanceType, but tied its to a borrow of the ComponentInstance (transitively the Store) which makes some new typechecking operations which have an AsContextMut impossible.

This has no direct benefit in this PR, but it split out of #10610 because it is more easily reviewed in isolation.

Having refs to a pair of arcs made it less expensive to create an
InstanceType, but tied its to a borrow of the ComponentInstance
(transitively the Store) which makes some new typechecking operations
which have an AsContextMut impossible.

This has no direct benefit in this PR, but it split out of #10610
because it is more easily reviewed in isolation.
@pchickey pchickey requested a review from a team as a code owner April 18, 2025 18:51
@pchickey pchickey requested review from alexcrichton and removed request for a team April 18, 2025 18:51
@github-actions github-actions bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Apr 18, 2025
@@ -355,7 +355,7 @@ impl<'a, T> LowerContext<'a, T> {

/// Returns the instance type information corresponding to the instance that
/// this context is lowering into.
pub fn instance_type(&self) -> InstanceType<'_> {
pub fn instance_type(&self) -> InstanceType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked briefly about this on Zulip, but this is the call that I'm worried about perf-wise. This is used during lifting/lowering of ResourceAny (transitively through the resource_type helper method which delegates to this one). I'd prefer to keep the Arc-cloning off the hot path there if possible, but I need to read up more on the other PR for better understanding the motivation behind this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, thanks for finding where it was in the hot path, I missed that. If for some reason the approach you outlined in #10610 doesn't cash out I will at very least make sure we can amortize the clone to only happen once per store, so it doesn't hurt resource lifting/lowering.

@pchickey
Copy link
Contributor Author

Replaced by #10621

@pchickey pchickey closed this Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasmtime:api Related to the API of the `wasmtime` crate itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants