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

[RUNTIME] add ability to terminate/pause/resume a wasm program #84

Merged
merged 8 commits into from
Mar 15, 2023

Conversation

Officeyutong
Copy link
Contributor

I write a new function run_wasm_bpf_module_async to provide the ability to run a wasm program async and to control it.

  • It has the same signature as run_wasm_bpf_module.
  • This function will return immediately after calling, and leave the wasm program running in another thread
  • It will return two handles. WasmProgramHandle provides ability to pause/resume/terminate a wasm program. JoinHandle provides the ability to wait for the finish of the wasm program.
  • I use the epoch interruption and the corresponding callback function (which will block the execution of the wasm program) to implement the functions. See https://docs.rs/wasmtime/latest/wasmtime/struct.Store.html#method.epoch_deadline_callback for details.
  • I use mpsc channels to implement inter-thread communication. For example, send ProgramOperation::Resume signal to a hanging thread which is stuck on receiving the next operation.

@Officeyutong Officeyutong marked this pull request as ready for review March 14, 2023 16:54
@codecov
Copy link

codecov bot commented Mar 14, 2023

Codecov Report

Merging #84 (9deef0c) into main (3b07511) will increase coverage by 0.54%.
The diff coverage is 92.15%.

❗ Current head 9deef0c differs from pull request most recent head 2cf43b0. Consider uploading reports for the commit 2cf43b0 to get more accurate results

@@            Coverage Diff             @@
##             main      #84      +/-   ##
==========================================
+ Coverage   79.04%   79.58%   +0.54%     
==========================================
  Files          12       14       +2     
  Lines        1188     1264      +76     
==========================================
+ Hits          939     1006      +67     
- Misses        249      258       +9     
Impacted Files Coverage Δ
runtime/wasm-bpf-rs/src/pipe.rs 34.18% <31.57%> (-3.43%) ⬇️
runtime/wasm-bpf-rs/src/handle.rs 93.75% <93.75%> (ø)
runtime/wasm-bpf-rs/src/lib.rs 83.87% <95.00%> (-4.47%) ⬇️
runtime/wasm-bpf-rs/src/runner.rs 100.00% <100.00%> (ø)
runtime/wasm-bpf-rs/src/state.rs 95.31% <100.00%> (-0.23%) ⬇️
runtime/wasm-bpf-rs/src/tests/mod.rs 99.21% <100.00%> (+0.11%) ⬆️

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@yunwei37 yunwei37 linked an issue Mar 14, 2023 that may be closed by this pull request
runtime/wasm-bpf-rs/src/handle.rs Show resolved Hide resolved
runtime/wasm-bpf-rs/tests/tick/.gitignore Show resolved Hide resolved
runtime/wasm-bpf-rs/src/lib.rs Outdated Show resolved Hide resolved
@yunwei37
Copy link
Member

nice job!

@yunwei37 yunwei37 merged commit 52d9655 into eunomia-bpf:main Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] add api to stop an wasm-bpf program
2 participants