Skip to content

Conversation

@yasunariw
Copy link
Contributor

Setting the lwt engine to poll at the top level here causes unexpected behavior when the library is used. On Linux, it overrides the default engine, which is libev.

@yasunariw yasunariw requested a review from rr0gi November 11, 2025 09:53
@rr0gi
Copy link
Contributor

rr0gi commented Nov 13, 2025

libev is default if it is available (both opam package and c library during lwt build), otherwise default is select which is worse than poll (limit on 1024 fd) and poll is guaranteed to be available. So ideally the fix should be - check if engine is select and if so - switch to poll, otherwise do nothing

@yasunariw
Copy link
Contributor Author

check if engine is select

I didn't find a way to do this, engine is object with no way to identify afaics
https://github.com/ocsigen/lwt/blob/master/src/unix/lwt_engine.mli

Instead I made it check for libev availability, and use poll if not available

*)
let () =
Lwt_engine.set @@ new Lwt_engines.poll
if not (Lwt_config._HAVE_LIBEV && Lwt_config.libev_default) then begin
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@rr0gi rr0gi merged commit 8bb7d7f into master Nov 24, 2025
2 of 3 checks passed
@yasunariw yasunariw changed the title prelude: don't set Lwt_engine at top level prelude: don't set Lwt_engine to poll if libev is available Nov 26, 2025
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.

3 participants