Skip to content
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

refactor(*): refactor wasm bytes preparation logic to the core crate #448

Closed
wants to merge 1 commit into from

Conversation

Mossaka
Copy link
Member

@Mossaka Mossaka commented Jan 12, 2024

This PR refactors the common Source logic from runtime shim to the core crate. To do so, the core Engine trait API has a breaking change:

  1. run_wasi() now takes a wasm_bytes: &[u8] parameter as the wasm module / component loaded from the file system or OCI layers to execute.

cc @jsturtevant

Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
@jprendes
Copy link
Collaborator

I think I would prefer if Source provided a method called to_bytes, that would encapsulate this logic, rather than changing the run_wasi signature.

@jsturtevant
Copy link
Contributor

The background is that we had something similiar to to_bytes but this had a clone #401 (comment). Maybe I've got it wrong in that thread about trying to avoid a clone on that call?

I am also not a fan of these changes to the run_wasi trait

@jprendes
Copy link
Collaborator

The clone could be avoided returning a Cow<[u8]> IIUC.

@jprendes
Copy link
Collaborator

Alternatively, in the case of File the bytes could be cached to avoid reading the file multiple times (something like a OnceCell or OnceLock), and then the &[u8] would refer to the bytes owned by the cache.

@Mossaka
Copy link
Member Author

Mossaka commented Jan 18, 2024

@jprendes thanks for the suggestion of Cow! I re-implement the refactor in #454

@Mossaka
Copy link
Member Author

Mossaka commented Jan 18, 2024

Close in favor of #454

@Mossaka Mossaka closed this Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants