-
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
WIP: libsubprocess: support flow control on writes via credits #6353
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6353 +/- ##
==========================================
- Coverage 83.32% 83.31% -0.01%
==========================================
Files 523 523
Lines 86189 86258 +69
==========================================
+ Hits 71816 71865 +49
- Misses 14373 14393 +20
|
In that PR I proposed that an {
"type":"add-credit",
"channels":{
"stdin":42
}
} while I think you are using {
"type":"add-credit",
"channel":{
"stream":"stdin",
"bytes":42
}
} The former is fewer bytes on the wire and leaves the door open to combine messages for multiple streams, should that be useful. What issue did you run into? BTW the main use case I was thinking of for combining messages was at initialization (server sends |
Lemme see if I can refactor it that way. |
Ahhh tried to refactor and realized why it initially didn't work out. The
i.e. only one stream and "bytes" is reported at a time. For remote subprocesses I just report the initial credits that the local subprocess reports. Could have a special case flag where local subprocess doesn't report initial credits and remote subprocess could "collate" them in one RPC instead? |
It's a bit unfortunate if we have to wait for the reactor loop to tell us the initial buffer size before sending it to the remote user since we should already know what it is and that adds latency. Still, is there a reason not to support multiple streams in the protocol even if this server doesn't use it yet? There are other subprocess servers ( |
Perhaps some special casing should be done here. Let me think about it.
Fair enough. |
d29b711
to
eb6e6e5
Compare
added tweaks to |
Ooh nice, does it work for an even smaller buffer like 4K? |
Yup, seems to work! |
Problem: libsubprocess iostress tests only support "API" or "direct" writes in tests. Currently a simple boolean is used in the tests to determine which write to use. But in the near future other options may be available. Refactor the iostress tests to use an enum rather than boolean to indicate how subprocess writes should happen.
Problem: In libsubprocess iostress tests, stdin input for tests is generated in a prep watcher. However, in future tests the input will be needed in other callbacks. Generate the stdin input earlier during test launch time. It will be available for all potential tests and callbacks.
Problem: The notify callback variables are all named "cb". This will be confusing when a future callback is added. Rename all notify callback variables from "cb" to "notify_cb".
Problem: It would be useful for developers to have a defined macro indicating the default stdio or channel buffer size. But the macro for the default is hidden in a private header file. Move SUBPROCESS_DEFAULT_BUFSIZE from a private header to a public one.
Problem: It would be convenient to be notified when data has been read from a buffer, so that more can be written into it. Support a credit callback. The callback will be called after some data has been read out of the buffer and inform the caller of the number of bytes read. Add unit tests.
Problem: Watcher priorities are only configurable in check watchers, but would be useful in prepare watchers as well. Add support for prepare watcher priorities. Add unit tests.
Problem: It would be convenient for libsubprocess users to know when write buffers have more space available for writing. However, there is no mechanism for that. Support a new on_credit callback that will inform the user that space is available in the write buffer. Fixes flux-framework#6291
Problem: There is no coverage for the new libsubprocess on_credit callback. Add unit tests in libsubprocess/test/stdio.c and libsubprocess/test/iostress.c.
Problem: libsubprocess now supports stdin flow control via credits, but that is not used in flux-exec. Support credits and flow control in flux-exec to avoid overflowing the stdin buffer. Fixes flux-framework#4572
eb6e6e5
to
4f7aa82
Compare
re-pushed, fixing up a lot of things based on comments above. Most notably, the remote subprocess sends out a single "initial credits" RPC back to the client for all channels. Could use some tests that have more than just the single stdin channel. That's a TODO. But I think I can split out an obvious commit from here. |
Per flux-framework/rfc#427 and discussion in #4572.
Some minor tweaks to the
add-credit
RPC. I think the design in the RFC assumed multiple channels would return credits at the same time, but I think that is impractical, so it's just credits for each channel.Haven't tested that this works by adding support in
flux-exec
yet. Just thought I'd post this initial work. May split off the cleanup into another PR.