Skip to content

Conversation

@garlick
Copy link
Member

@garlick garlick commented Jul 3, 2025

Problem: as discussed in #3969, it is hard to embed the flux reactor in another event loop because it doesn't expose an interface for notification when events are pending (such as a file descriptor). It cannot, because libev does not. libuv does, hence the interest in replacing libev with libuv.

This PR adds a new configure option:

  --with-libuv            Use libuv for event loop (experimental)

When configured that way, libev is replaced with libuv. However, this is still a WIP due to:

  • missing periodic watchers
  • flux_watcher_set_priority() isn't implemented (we support it for check watchers only)
  • running the reactor unit test under valgrind shows a memory leak
  • there is an unexplained segfault in the composite watcher unit test

Given the experimental label, perhaps we could merge this if we could do the following:

Then when the reactor embedding issue priority goes up again at some point, perhaps someone can pick this up and resolve any remaining issues.

See also

garlick added 6 commits July 3, 2025 05:09
Problem: flux-core only supports libev (vendored or external).

Add a --with-libuv configure option which causes HAVE_LIBUV to
be defined in config.h and defines LIBUV to be tested in Makefile.am's.

Rename --with-external-libev to --with-libev to match.

If neither --with-libev nor --with-libuv are specified, use vendored libev.
Problem: if ev_loop() fails in flux_reactor_create(), the
destructor is called with a reference count that causes it
to do nothing.

Just call free instead of calling the destructor.
Problem: flux_watcher_destroy() could clobber errno.

Save/restore errno within the function.
Problem: supporting both libuv and libev in watcher_wrap.c with
preprocessor ifdefs will be a mess.

Rename watcher_wrap.c to watcher_ev.c in anticipating of adding
a separate watcher_uv.c version.
Problem: the flux reactor lacks an interface for embedding
in other reactors.

libev doesn't offer access to a file descriptor that becomes
ready when events are pending.  However, libuv provides
uv_backend_fd().  Therefore, let's begin a port of libuv
to Flux.

This commit creates an alternate libflux reactor implementation
based on libuv that is selected when flux-core is configured
--with-libuv.  Reactor watchers are dealt with in a separate
commit.
Problem: the libuv port lacks Flux watcher implementations.

Add implementations for the built-in Flux watchers, except
periodic watchers.

flux_watcher_set_priority() is not implemented.
@codecov
Copy link

codecov bot commented Jul 3, 2025

Codecov Report

Attention: Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 83.83%. Comparing base (a39f650) to head (730cb72).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/common/libflux/reactor.c 92.30% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6902   +/-   ##
=======================================
  Coverage   83.83%   83.83%           
=======================================
  Files         539      539           
  Lines       90269    90268    -1     
=======================================
+ Hits        75674    75678    +4     
+ Misses      14595    14590    -5     
Files with missing lines Coverage Δ
src/common/libflux/watcher.c 100.00% <100.00%> (ø)
src/common/libflux/watcher_ev.c 97.03% <ø> (ø)
src/common/libflux/reactor.c 94.73% <92.30%> (-0.27%) ⬇️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant