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

Switch to rquickjs #618

Merged
merged 23 commits into from
May 2, 2024
Merged

Conversation

saulecabrera
Copy link
Member

@saulecabrera saulecabrera commented Mar 19, 2024

Description of the change

Historically, the Javy project has relied on its own QuickJS bindings in order to consume QuickJS' functionality. When the project started, there were very limited options for bindings that could work for our use-case and more importantly, bindings that would compile to wasm32-wasi. That said, bindings under this project are "good enough" for Javy, but they are probably not the most ergonomic for use-cases that require more complex interactions with QuickJS.

The Rust <> QuickJS landscape has changed in the past few years, which means that it's probably a good time to reconsider our initial decisions.

This PR proposes migrating to rquickjs and dropping support for quickjs-wasm-rs and quickjs-wasm-sys. The rquickjs bindings are more ergonomic and enable more natural interactions between Rust and QuickJS' API.

With the adoption of rquickjs, we'd be able to address issues like: #605, #608, #617 and #611.

This change is divided in a series of commits, but it's better reviewed as a whole, given that I didn't put enough thought to make each commit self-contained.

In general, this change doesn't introduce any functional changes, dropping support for quickjs-wasm-rs is the only breaking change introduced by this PR. The only exception is that I fixed a bug in our number deserialization process, in which the implementation was not respecting the MIN_SAFE_INTEGER..=MAX_SAFE_INTEGER range.

This change is already big as-is; I'm planning on creating follow-up PRs for:

  • Updating the documentation under docs
  • Update the READMEs for quickjs-wasm-rs and quickjs-wasm-sys with a deprecation notice.

Checklist

  • I've updated the relevant CHANGELOG files if necessary. Changes to javy-cli and javy-core do not require updating CHANGELOG files.
  • I've updated the relevant crate versions if necessary. Versioning policy for library crates
  • I've updated documentation including crate documentation if necessary.

Migrated the `Console` and `Random` APIs; got to the `StreamIO` API.
@saulecabrera saulecabrera mentioned this pull request Mar 19, 2024
3 tasks
This commit migrates the `console`, `stream_io`, `random` and `text_encoding`  APIs to use rquickjs. 

One notable change in this commit is the introduction of the `Args` struct to tie the lifetime of `Ctx<'js>` and `Rest<Value<'js>>` arguments, given that explicit lifetime binding is not possible in Rust closures at the moment.
@saulecabrera saulecabrera marked this pull request as ready for review April 11, 2024 01:38
@saulecabrera
Copy link
Member Author

Not quite ready for review, but almost. I want to see what CI says.

Copy link
Collaborator

@surma surma left a comment

Choose a reason for hiding this comment

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

I know you didn’t solicit a review and I didn’t really do a full review, but I wanted to take a look where you are at and left 2 comments :3

crates/apis/src/console/mod.rs Outdated Show resolved Hide resolved
crates/javy/src/lib.rs Show resolved Hide resolved
@saulecabrera
Copy link
Member Author

Ok, so all tests are passing here. I'm working on migrating our json/msgpack ser/de and that should be the last step (aside from vetting the new dependencies) to get this in a review-ready state.

@saulecabrera saulecabrera requested review from surma, makrisoft and jeffcharles and removed request for makrisoft April 16, 2024 01:14
I wanted to avoid as much as possible using the underlying QuickJS unsafe APIs, but that introduced behavioral changes and bugs. So for now, I'm sticking to the previous implementation.
Copy link
Collaborator

@jeffcharles jeffcharles left a comment

Choose a reason for hiding this comment

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

We should update the READMEs for quickjs-wasm-sys and quickjs-wasm-rs to indicate they are deprecated in favour of rquickjs. Would that make sense to do as part of this PR or in a follow up one?

crates/apis/src/stream_io/mod.rs Outdated Show resolved Hide resolved
crates/apis/src/stream_io/mod.rs Outdated Show resolved Hide resolved
crates/core/src/lib.rs Outdated Show resolved Hide resolved
crates/javy/src/runtime.rs Outdated Show resolved Hide resolved
crates/javy/src/runtime.rs Outdated Show resolved Hide resolved
@saulecabrera
Copy link
Member Author

We should update the READMEs for quickjs-wasm-sys and quickjs-wasm-rs to indicate they are deprecated in favour of rquickjs. Would that make sense to do as part of this PR or in a follow up one?

I'll do that as a follow-up. I added an entry in the PR description.

Copy link
Collaborator

@jeffcharles jeffcharles left a comment

Choose a reason for hiding this comment

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

This is going to make things so much nicer! Thank you for doing this.

@saulecabrera
Copy link
Member Author

Oops meant to push 5fde19c, into a copy branch to do some testing -- I'll revert it.

This commit introduces rquickjs 0.6.0 through a fork that contains Wasm specific performance improvements. We intend to upstream these improvements.
Adds special policy for rquickjs given that we're currently in a fork.
@saulecabrera saulecabrera merged commit 235b5a6 into bytecodealliance:main May 2, 2024
14 checks passed
@saulecabrera saulecabrera deleted the javy-rquickjs branch May 2, 2024 11:17
@jbourassa jbourassa mentioned this pull request May 3, 2024
3 tasks
saulecabrera added a commit to saulecabrera/javy that referenced this pull request May 6, 2024
This commit is a follow-up to bytecodealliance#618, to formally mark `quckjs-wasm-{sys, rs}` crates as deprecated.

The rollout strategy is to:

* Merge this PR
* Publish the a new version of each of the crates, containing the last unreleased change in each and the deprecation notice.
saulecabrera added a commit that referenced this pull request May 7, 2024
This commit is a follow-up to #618, to formally mark `quckjs-wasm-{sys, rs}` crates as deprecated.

The rollout strategy is to:

* Merge this PR
* Publish the a new version of each of the crates, containing the last unreleased change in each and the deprecation notice.
@redoC-A2k
Copy link

redoC-A2k commented May 18, 2024

Thanks a lot for doing rquickjs switch work .Till when can I expect the new release on github roughly ?

@saulecabrera
Copy link
Member Author

Mid June is my estimate: we're doing more extensive testing and working on other improvements before releasing the next version.

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

5 participants