janet-lang / janet

A dynamic language and bytecode vm
https://janet-lang.org
MIT License
3.38k stars 217 forks source link

After a stream is created ev/sleep takes 100% CPU. #1321

Closed bitcompost closed 8 months ago

bitcompost commented 8 months ago

Steps to reproduce:

Janet 1.32.1-meson linux/aarch64/gcc - '(doc)' for help
repl:1:> (net/connect "1.1.1.1" "80")
<core/stream 0xAAAACB3E0010>
repl:2:> (ev/sleep 42)
bakpakin commented 8 months ago

Cannot reproduce on linux/x64. Is this for some reason only arm? Also would be interested in your linux kernel version.

bitcompost commented 8 months ago

I can reproduce it on x64. Kernel 6.2.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 6 10:23:26 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

bitcompost commented 8 months ago

Did some more testing. It only hapens with the meson build.

bakpakin commented 8 months ago

Ok, looks like the meson build by default is using the poll event loop instead of the epoll event loop, so the bug is with the poll event loop.

With meson, you can fix this for now using

meson setup build -Depoll=true

when configuring the project (and get more efficient as well).