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

(playground) Aborts cause state loss. #56

Open
Jean-Luc-Picard-2021 opened this issue Aug 5, 2022 · 6 comments
Open

(playground) Aborts cause state loss. #56

Jean-Luc-Picard-2021 opened this issue Aug 5, 2022 · 6 comments
Labels

Comments

@Jean-Luc-Picard-2021
Copy link

Jean-Luc-Picard-2021 commented Aug 5, 2022

Hi,

Not sure whether this ticket is redundant to "(ciaowasm) make '$yield'/0
interact with JS async" what is seen in the commits?

There is some state loss in manual abort:

?- assertz(foo).
yes

?- foo.
yes

?- repeat, fail.
{ Execution aborted }

?- foo.
{ERROR: No handle found for thrown exception error(
existence_error(procedure,'user:foo'/0),'user:foo'/0)}
aborted

And in timeout:

?- assertz(foo).
yes

?- repeat, fail.
{ABORTED: Time limit exceeded.}

?- foo.
{ERROR: No handle found for thrown exception error(
existence_error(procedure,'user:foo'/0),'user:foo'/0)}
aborted

https://ciao-lang.org/playground/

Expectation would be rather that this doesn't happen.

@jfmc jfmc added the bug label Aug 5, 2022
@jfmc jfmc transferred this issue from ciao-lang/ciao_playground Aug 5, 2022
@jfmc jfmc changed the title Aborts cause state loss. (playground) Aborts cause state loss. Aug 5, 2022
@jfmc
Copy link
Member

jfmc commented Aug 5, 2022

Thank you. This is a known limitation similar to blocking IO. Timeouts are hard without asyncify or shared array buffers because there is no way for the executing thread to know that it has been asked to abort. Asyncify should be able but we've not measured the performance impact yet. Right now aborts restart the engine.

@Jean-Luc-Picard-2021
Copy link
Author

Jean-Luc-Picard-2021 commented Aug 8, 2022

Works in Jan W prototype, but his prototype is still a little slow.

https://dev.swi-prolog.org/wasm/shell

?- assertz(foo).
true.

?- foo.
true.

?- repeat, fail.
ERROR: Execution Aborted

?- foo.
true.

The version I am reporting uses a setTimout() driven auto yielding loop.
Through setTimeout() you give the browser the chance to
work its task queues, it will do all kind of stuff, in the above

example the browser stays responsive during repeat, fail,
please try it, it does all that without a Worker. I guess this is
a nice first proof of concept and one of the goals of this work.

@Jean-Luc-Picard-2021
Copy link
Author

You also see here that it doesn’t have any Workers, there
is no Threads tab in the debugger. But interesting find, SWIPL itself
got promisified, and the very first next() call goes through toplevel():

2f6e0188abff96c680da7a91d0af4f29fc849c62

@jfmc
Copy link
Member

jfmc commented Aug 8, 2022

Thanks. Sorry, I was confused with the long thread at SWI discourse. We'll try automatic yield but if there is some serious impact on performance, we will consider also other options (maybe optionally). For some workers losing the state is not an issue.

@Jean-Luc-Picard-2021
Copy link
Author

Jean-Luc-Picard-2021 commented Aug 8, 2022

Now Jan W prototype got faster, but I don't have yet a live link to share.

@jfmc
Copy link
Member

jfmc commented Jul 29, 2023

Not fixed yet.

@jfmc jfmc reopened this Jul 29, 2023
@jfmc jfmc reopened this May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants