Skip to content

Conversation

Hywan
Copy link
Contributor

@Hywan Hywan commented Mar 6, 2019

Fix #4.

This PR replaces wasmi by Wasmer through the wasmer-runtime-c-api, and thus we will be able to use Cranelift and soon LLVM for the backend.

@Hywan Hywan added the 🎉 enhancement New feature or request label Mar 6, 2019
@Hywan Hywan self-assigned this Mar 6, 2019
@Hywan Hywan changed the title Migrate from wasmi to wasmer [WIP] Migrate from wasmi to wasmer Mar 6, 2019
Hywan added 16 commits March 8, 2019 10:49
Note that the `WASM_SIGNATURE_TYPE_VOID` has been removed for now.
The initial function was named `wasm_read_binary`. The new name is
`wasm_read_bytes`.
The value stored in the `wasm_bytes` resource has changed from
`uint8_t*` to `wasmer_byte_array*`.

The signature of the `wasm_new_instance` function no longer requires
the Wasm binary filename. The last argument has been removed
temporarily.
The function name is updated to `wasm_function_arguments_builder`.
This patch also restores the `wasm_function_arguments_builder_add_i32`.
Previously named `wasm_invoke_arguments_builder_add_i64`.
… function.

Previously named `wasm_invoke_arguments_builder_add_f32`.
… function.

Previously named `wasm_invoke_arguments_builder_add_f64`.
@Hywan
Copy link
Contributor Author

Hywan commented Mar 8, 2019

Early results with the n-body benchmark.

Note: I'm testing with PHP 7.3.2.

Rust only

$ hyperfine './nbody-rs 5000000'
Benchmark #1: ./nbody-rs 5000000

  Time (mean ± σ):     287.0 ms ±   8.1 ms    [User: 280.5 ms, System: 2.8 ms]

  Range (min … max):   278.5 ms … 300.5 ms

Pure PHP

$ hyperfine 'php nbody.pure.php 5000000'
Benchmark #1: php nbody.pure.php 5000000

  Time (mean ± σ):     19.761 s ±  0.842 s    [User: 19.602 s, System: 0.075 s]

  Range (min … max):   18.908 s … 20.915 s

php-ext-wasm with wasmi

$ hyperfine 'php -d extension=wasm nbody.wasm.php'
Benchmark #1: php -d extension=wasm nbody.php

 ⠦ Current estimate: 67.622 s     ███████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ETA 00:18:02
^C

I stopped the benchmark, I didn't want to wait 18mn.

🆕 php-ext-wasm with wasmer

$ hyperfine 'php -d extension=wasm nbody.wasm.php'
Benchmark #1: php -d extension=wasm nbody.wasm.php

  Time (mean ± σ):      2.365 s ±  0.266 s    [User: 2.284 s, System: 0.047 s]

  Range (min … max):    2.014 s …  2.864 s

Conclusion

Implementation Time (ms)
Rust (baseline) 287
Pure PHP 19'761
php-ext-wasm with wasmi (current) 67'622
php-ext-wasm with wasmer (this PR) 2365

@Hywan
Copy link
Contributor Author

Hywan commented Mar 11, 2019

Blocked by wasmerio/wasmer#261

@Hywan Hywan changed the title [WIP] Migrate from wasmi to wasmer Migrate from wasmi to wasmer Mar 12, 2019
@Hywan Hywan merged commit 2ba7a86 into master Mar 12, 2019
@Hywan Hywan deleted the wasmer branch March 12, 2019 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🎉 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants