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

Switching Vireo to Wasm from asm.js #512

Merged
merged 31 commits into from
Sep 27, 2018

Conversation

rajsite
Copy link
Member

@rajsite rajsite commented Sep 24, 2018

Major changes:

  • Updating emscripten version
  • Switching to ES6 Module format for JavaScript source
  • Switching from a synchronous constructor (new Vireo()) to asynchronous (vireoHelpers.createInstance())
  • Change executeSlicesUntilClumpsFinished from being callback-based to being Promise-based

Note: It looks like a lot of files changes buts that mostly because two lines had to change in every JS test.
It was unavoidable due WebAssembly requiring async construction.

The actual changes are pretty well localized to the build scripts and the loader js files.

Now that the wasm is in a seperate file, it makes debugging easier to avoid minifying the vireo.js module. An end user can minify the rollup output if desired.
Found that WASM aggressive traps on numeric conversions caused exceptions (caused by overflow, double to int conversion, etc). Changed trap behavior to clamp numerics instead.
Based on feedback that the previous requestInstance could be confused with requesting from a singleton so changing to createInstance.
And mark the workarounds used for legacy browsers as optional and removable if needed.
Some changes have happened in emsdk that actually update the PATH correctly so running a seperate command and environment is not needed
and no longer accept callbacks. This is an improvement because it gives a better way to report fatal errors that have occurred during exxecution of the Vireo runtime.
These manual tests verify that vireo loads into memory in different scenarios such as global in browser, AMD in browser, ES6 module in browser, CommonJS in node, Web Workers, etc.
Some of the test runs execute significantly slower and increase build times by a lot (total 12min -> 35min).

It does not seem worth it to execute every configuration on the CI.

Only enabling the test-min run since that reflects the build executed by users.
With the JS math mode enabled the coerced values behave as expected. If the mode is ever changed these tests will fail and can be investigated further.
Copy link
Contributor

@gleono gleono left a comment

Choose a reason for hiding this comment

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

Looks great! So excited to start using ES6 features along with wasm 😄

karma.conf.js Show resolved Hide resolved
test-it/karma/helloworld/HelloWorld.Test.js Outdated Show resolved Hide resolved
Copy link
Contributor

@cglzaguilar cglzaguilar left a comment

Choose a reason for hiding this comment

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

Great work @rajsite! Please address minor feedback and questions.

test-it/ManualLoaderTests/loaderglobal_httpget.html Outdated Show resolved Hide resolved
test-it/ViaTests/HttpBinGet.via Show resolved Hide resolved
package.json Show resolved Hide resolved
Copy link
Contributor

@cglzaguilar cglzaguilar left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@spathiwa
Copy link
Contributor

This looks great!
But is there a good reason to get rid of the asm.js target completely and move to wasm in one go?
It seems like keeping both targets would be good at least initially; if we find performance or behavior changes it might be useful to build the asm.js version and compare.

Copy link
Contributor

@spathiwa spathiwa left a comment

Choose a reason for hiding this comment

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

Approved, with question about keeping asm.js target if possible.

Previously findValueRef and findSubValueRef threw an Error for nonexistant paths. In general throwing an error from the Vireo API functions means that Vireo is in an unrecoverable state.

However, there were tests that would cause errors to be thrown for nonexistent paths but continue to use the Vireo instance for additional tests. This now resulted in failures in the asm.js buid after a compiler upgrade.

Instead of modifying the tests to use new Vireo instances between runs, the behavior of findValueRef and findSubValueRef was modified to safely return undefined if a path is not found. This has been a desired behavior on the ASW side as well.
@rajsite
Copy link
Member Author

rajsite commented Sep 26, 2018

@spathiwa Initially had tried to support both asm.js and wasm with the old UMD module system but that was very complex. After switching ES6 modules it simplified a lot of pieces and it wasn't too bad to have both wasm and asm.js builds supported so both are now enabled.

The asm.js build also revealed a problem that existed in the tests and that mainline relied on and is now cleaned up so it was a nice bit that was uncovered.

I'm resetting @cglzaguilar and @gleonoliva to buddy that api behavior change.

Edit: Okay, I can't actually reset people, but if @cglzaguilar and @gleonoliva could take a gander at those parts that would be great

@rajsite rajsite requested review from gleono and removed request for gleono September 26, 2018 01:11
@spathiwa
Copy link
Contributor

Again, great job!

@sanmut
Copy link
Contributor

sanmut commented Sep 26, 2018

The asm.js build also revealed a problem that existed in the tests and that mainline relied on and is now cleaned up so it was a nice bit that was uncovered.

This is awesome. Thanks for building both.

@sanmut
Copy link
Contributor

sanmut commented Sep 26, 2018

Looks great. Go WASM and Go ES6 !!!

Copy link
Contributor

@sanmut sanmut left a comment

Choose a reason for hiding this comment

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

Posted a few questions. Other than that, looks good to submit.

  • Please merge this only when ready to create a release and quickly update ASW side.
  • Please do run ASW side CI test
  • Please run a couple of our big example projects with Skyline/HTTP APIs, .

make-it/EmMakefile Outdated Show resolved Hide resolved
make-it/EmMakefile Outdated Show resolved Hide resolved
@gleono
Copy link
Contributor

gleono commented Sep 26, 2018

I had a second look at it. It looks great! I think it makes more sense now that findValueRef and findSubValueRef return undefined, it also looks cleaner. Thanks for fixing the issues in those tests.

@gleono
Copy link
Contributor

gleono commented Sep 26, 2018

Also I just noticed that this is the 2^9 pull request to VireoSDK 🙌 🎉

Copy link
Contributor

@cglzaguilar cglzaguilar left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@rajsite
Copy link
Member Author

rajsite commented Sep 26, 2018

Ran the tests suggested by @sanmut just waiting on ASW PR

@rajsite rajsite merged commit 75af816 into ni:master Sep 27, 2018
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.

7 participants