Skip to content

modified poll_oneoff to make it interruptible#1951

Merged
wenyongh merged 1 commit intobytecodealliance:mainfrom
hritikgupta:polloneoff
Feb 16, 2023
Merged

modified poll_oneoff to make it interruptible#1951
wenyongh merged 1 commit intobytecodealliance:mainfrom
hritikgupta:polloneoff

Conversation

@hritikgupta
Copy link
Contributor

No description provided.

@hritikgupta hritikgupta force-pushed the polloneoff branch 2 times, most recently from 6516265 to b69d3f2 Compare February 13, 2023 14:50
@hritikgupta hritikgupta force-pushed the polloneoff branch 2 times, most recently from 0b790e0 to bf8e2ea Compare February 13, 2023 17:50
@hritikgupta hritikgupta requested a review from loganek February 13, 2023 17:52
@hritikgupta hritikgupta force-pushed the polloneoff branch 2 times, most recently from 84b1ba8 to ce45358 Compare February 14, 2023 01:42
@hritikgupta hritikgupta force-pushed the polloneoff branch 2 times, most recently from b86c025 to 101e2f1 Compare February 14, 2023 15:44
@hritikgupta hritikgupta force-pushed the polloneoff branch 2 times, most recently from a6d704f to 477692c Compare February 14, 2023 23:43
Copy link
Collaborator

@wenyongh wenyongh left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@loganek loganek left a comment

Choose a reason for hiding this comment

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

LGTM, left some minor comments.

@eloparco
Copy link
Contributor

@wenyongh can we merge main into dev/wasi_threads once this PR is merged?

@wenyongh
Copy link
Collaborator

@wenyongh can we merge main into dev/wasi_threads once this PR is merged?

Sure, will do that soon.

size_t *nevents, uint32 *nevents_app)
{
if (nsubscriptions == 0)
return 0;
Copy link
Collaborator

@wenyongh wenyongh Feb 16, 2023

Choose a reason for hiding this comment

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

Had better set *nevents_app = 0 before return success.

Copy link
Contributor Author

@hritikgupta hritikgupta Feb 16, 2023

Choose a reason for hiding this comment

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

wouldn't that anyway happen on L1077, given we have now initialised nevents to 0?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, that's really an issue, not sure why the prototype of execute_interruptible_poll_oneoff isn't same as wasmtime_ssp_poll_oneoff. My understanding is that we should define them as same prototype.

Copy link
Contributor Author

@hritikgupta hritikgupta Feb 16, 2023

Choose a reason for hiding this comment

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

it's mostly the same (that's what my intent was too) except for two arguments i.e. module_inst which needs to be passed to check if there are any exceptions that occurred & nevents_app

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, adding module_inst is OK, but how about removing nevents_app? It is duplicated set inside execute_interruptible_poll_oneoff and after calling it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, removed nevents_app

Copy link
Collaborator

@wenyongh wenyongh left a comment

Choose a reason for hiding this comment

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

LGTM

@wenyongh wenyongh merged commit 50650e4 into bytecodealliance:main Feb 16, 2023
wenyongh pushed a commit that referenced this pull request Feb 23, 2023
…1980)

Fix issues in the libc-wasi `poll_oneoff` when thread manager is enabled:
-  The exception of a thread may be cleared when other thread runs into
   `proc_exit` and then calls `clear_wasi_proc_exit_exception`, so should not
   use `wasm_runtime_get_exception` to check whether an exception was
    thrown, use `wasm_cluster_is_thread_terminated` instead
- We divided one time poll_oneoff into many times poll_oneoff to check
   the exception to avoid long time waiting in previous PR, but if all events
   returned by one time poll are all waiting events, we need to continue to
   wait but not return directly.

Follow-up on #1951. Tested with multiple timeout values, with and without
interruption and measured the time spent sleeping.
yamt added a commit to yamt/wasm-micro-runtime that referenced this pull request Jan 24, 2024
While we used a different approach for poll_oneoff [1],
the implementation works only when the poll list includes
an absolute clock event. That is, if we have a thread which is
polling on descriptors without a timeout, we fail to terminate
the thread.

This commit fixes it by applying wasm_runtime_begin_blocking_op
to poll as well.

[1] bytecodealliance#1951
yamt added a commit to yamt/wasm-micro-runtime that referenced this pull request Jan 24, 2024
While we used a different approach for poll_oneoff [1],
the implementation works only when the poll list includes
an absolute clock event. That is, if we have a thread which is
polling on descriptors without a timeout, we fail to terminate
the thread.

This commit fixes it by applying wasm_runtime_begin_blocking_op
to poll as well.

[1] bytecodealliance#1951
yamt added a commit to yamt/wasm-micro-runtime that referenced this pull request Jan 24, 2024
While we used a different approach for poll_oneoff [1],
the implementation works only when the poll list includes
an absolute clock event. That is, if we have a thread which is
polling on descriptors without a timeout, we fail to terminate
the thread.

This commit fixes it by applying wasm_runtime_begin_blocking_op
to poll as well.

[1] bytecodealliance#1951
yamt added a commit to yamt/wasm-micro-runtime that referenced this pull request Jan 24, 2024
While we used a different approach for poll_oneoff [1],
the implementation works only when the poll list includes
an absolute clock event. That is, if we have a thread which is
polling on descriptors without a timeout, we fail to terminate
the thread.

This commit fixes it by applying wasm_runtime_begin_blocking_op
to poll as well.

[1] bytecodealliance#1951
wenyongh pushed a commit that referenced this pull request Jan 25, 2024
While we used a different approach for poll_oneoff [1],
the implementation works only when the poll list includes
an absolute clock event. That is, if we have a thread which is
polling on descriptors without a timeout, we fail to terminate
the thread.

This commit fixes it by applying wasm_runtime_begin_blocking_op
to poll as well.

[1] #1951
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
…ytecodealliance#1980)

Fix issues in the libc-wasi `poll_oneoff` when thread manager is enabled:
-  The exception of a thread may be cleared when other thread runs into
   `proc_exit` and then calls `clear_wasi_proc_exit_exception`, so should not
   use `wasm_runtime_get_exception` to check whether an exception was
    thrown, use `wasm_cluster_is_thread_terminated` instead
- We divided one time poll_oneoff into many times poll_oneoff to check
   the exception to avoid long time waiting in previous PR, but if all events
   returned by one time poll are all waiting events, we need to continue to
   wait but not return directly.

Follow-up on bytecodealliance#1951. Tested with multiple timeout values, with and without
interruption and measured the time spent sleeping.
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
…lliance#3080)

While we used a different approach for poll_oneoff [1],
the implementation works only when the poll list includes
an absolute clock event. That is, if we have a thread which is
polling on descriptors without a timeout, we fail to terminate
the thread.

This commit fixes it by applying wasm_runtime_begin_blocking_op
to poll as well.

[1] bytecodealliance#1951
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.

4 participants