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

Use the wasi functions for time retrieval, and yield less often to the JS engine #481

Merged
merged 7 commits into from
Apr 27, 2023

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Apr 26, 2023

Fix #418

@tomaka
Copy link
Contributor Author

tomaka commented Apr 26, 2023

Everything times out for some reason, and I don't understand why.

@tomaka
Copy link
Contributor Author

tomaka commented Apr 26, 2023

I think that it's because it's become so slow that the CPU is completely clogged.

@tomaka
Copy link
Contributor Author

tomaka commented Apr 26, 2023

The issue happens in cpu_rate_limiter.rs. Switching back to the old Instant in only that module fixes the issue.

I'm still completely missing what could be happening.

@tomaka
Copy link
Contributor Author

tomaka commented Apr 26, 2023

My hypothesis is that the change in precision in the time causes the CPU limiter to call setImmediate very very often, thus preventing any other JS task (such as the connection succeeding) from being executed.

@tomaka tomaka changed the title Use the wasi functions for time retrieval Use the wasi functions for time retrieval, and yield less often to the JS engine Apr 26, 2023
@tomaka
Copy link
Contributor Author

tomaka commented Apr 26, 2023

Confirmed that this was the issue.
We now call setTimeout and setImmediate only after we have accumulated 5ms of lack of sleep.
This solves the problem.

@tomaka tomaka added this pull request to the merge queue Apr 27, 2023
Merged via the queue into smol-dot:main with commit b42882d Apr 27, 2023
@tomaka tomaka deleted the fix-418 branch April 27, 2023 07:01
@tomaka tomaka mentioned this pull request Apr 27, 2023
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.

Update the bindings now that BigInt <-> i64 is stable
1 participant