-
Notifications
You must be signed in to change notification settings - Fork 50
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
libflux: refactor reactor/watcher implementation #6494
Open
garlick
wants to merge
8
commits into
flux-framework:master
Choose a base branch
from
garlick:reactor_cleanup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
garlick
force-pushed
the
reactor_cleanup
branch
from
December 9, 2024 21:34
2ad5ae1
to
8f3414f
Compare
Problem: some older code violates RFC 7 whitespace guidelines. Break long parameter lists to one per line.
Problem: watcher implementations are derefencing w->fn() but otherwise use accessors for struct watcher internals. Add watcher_call() to replace direct access to structure member.
Problem: the zmq watcher is implemented in an ambigously named source file. Use zwatcher.[ch] instead of reactor.[ch] Rename unit test too. Update include directives.
Problem: the zmq watcher is implemeted directly on libev which complicates changing the Flux reactor implementation to something else. Reimplement watcher using the Flux API.
Problem: the flux_t handle watcher is implemeted directly on libev which complicates changing the Flux reactor implementation to something else. Reimplement watcher using the Flux API. Move it to a new source file since it is now fairly standalone.
Problem: the subprocess internal "buffer watchers" are implemeted directly on libev which complicates changing the Flux reactor implementation to something else. Reimplement watcher using the Flux API.
Problem: the internal sdbus watcher is_active() callback calls ev_is_active() on a flux_watcher_t, which is accepted because ev_is_active() is a macro that casts its pointer argument. Although flux_watcher_is_active() is not currently used in the sdbus module (the only user of the watcher), fix the code in case it ever is.
Problem: the reactor and watcher implementations are unnecessarily exposed and co-mingled. Split up reactor.c, reactor.h (public), reactor_private.h into: reactor.c, reactor_private.h Only the reactor struct and implementation. Add an accessor for the ev_loop, to be used only in watcher_wrap.c watcher.c, watcher_private.h Only the watcher struct and generic "class" implementation. Add accessors to avoid exposing watcher struct details to watcher implementations. watcher_wrap.c Wrapped libev watcher implementations. These now use watcher accessors rather than directly accessing the watcher struct. A public watcher.h header is added to split out the public watcher interfaces from reactor.h. This was not strictly necessary, but reactor.h was a little busy. Users are still expected to just include <flux/core.h>. Update the zmq watcher, flux_t handle watcher, fbuf watchers, and sdbus watcher to include watcher_private.h and use watcher accessors. Replacing the inlines in reactor_private.h with actual functions in watcher.c necessitated linking some executables with src/common/libflux/watcher.lo. libev use is now localized to reactor.c and watcher_wrap.c, which should make transitioning to a new implementation somewhat easier than before. The code should also be easier to read and navigate.
garlick
force-pushed
the
reactor_cleanup
branch
from
December 11, 2024 21:19
8f3414f
to
f7d3cec
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6494 +/- ##
==========================================
- Coverage 83.63% 83.62% -0.02%
==========================================
Files 525 522 -3
Lines 87682 87669 -13
==========================================
- Hits 73334 73309 -25
- Misses 14348 14360 +12
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This was split off of an (aborted for now) effort to convert flux to libuv, mentioned in #6492.
This isolates the reactor and watcher implementations from each other somewhat, and also localizes libev calls to two source files.
Full disclosure: several watchers including the ones for zmq sockets,
flux_t
handles, and subprocess buffers are reimplemented in terms of the Flux API, which might introduce a few extra small mallocs per instance. This is because libev watchers are just structs that you initialize instead of opaque objects that you allocate, and each of these high level "composite watchers" contains three or four internal watchers that are nowflux_watcher_t
's. I can't imagine this is a big deal.