Skip to content

Commit 1602d14

Browse files
authored
Merge pull request #427 from garlick/rfc42_flowcontrol
rfc42: add credit based flow control for channels
2 parents ad0ae5c + ffca60e commit 1602d14

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

spec_42.rst

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ Goals
8585

8686
- Optionally forward additional I/O channels.
8787

88+
- Provide flow control on channels.
89+
8890
- Provide signal delivery capability.
8991

9092
- Protect against unauthorized use.
@@ -121,6 +123,10 @@ are defined as follows:
121123
channel (4)
122124
Forward auxiliary channel output to the client.
123125

126+
write-credit (8)
127+
Send ``add-credit`` exec responses when buffer space is available
128+
for standard input or writable auxiliary channels.
129+
124130
Several response types are distinguished by the type key:
125131

126132
.. object:: exec started response
@@ -179,6 +185,25 @@ Several response types are distinguished by the type key:
179185

180186
See `I/O Object`_ below.
181187

188+
.. object:: exec add-credit response
189+
190+
The subprocess server has more buffer space available to receive data
191+
on the specified channel. The response SHALL consist of a JSON object
192+
with the following keys:
193+
194+
.. object:: type
195+
196+
(*string*, REQUIRED) The response type with a value of ``add-credit``.
197+
198+
.. object:: channels
199+
200+
(*object*, REQUIRED) An object with channel names as keys and
201+
integer credit counts as values.
202+
203+
The server's initial response contains the full buffer size(s).
204+
205+
These messages are suppressed if the write-credit flag was not specified.
206+
182207
.. object:: exec error response
183208

184209
The :program:`exec` response stream SHALL be terminated by an error
@@ -219,6 +244,31 @@ This request receives no response, thus the request message SHOULD set
219244
FLUX_MSGFLAG_NORESPONSE. Write Requests to invalid channel names MAY be
220245
ignored by the subprocess server.
221246

247+
Input Flow Control
248+
------------------
249+
250+
A client MAY track a channel's free remote buffer space :math:`L`:
251+
252+
- :math:`L` is initialized to zero
253+
254+
- Each :program:`exec add-credit` response adds credits to :math:`L`
255+
256+
- Each :program:`write` request subtracts the unencoded data length
257+
from :math:`L`.
258+
259+
A client MAY avoid the risk of overrunning the remote buffer by ensuring
260+
a :program:`write` request never sends more than :math:`L` bytes of data.
261+
262+
To avoid unnecessary start-up delays, a client MAY "borrow credit" up to
263+
the remote buffer size before the first :program:`exec add-credit` response.
264+
In that case :math:`L` would have a negative value until the first
265+
:program:`exec add-credit` response is received.
266+
267+
Servers SHALL implement a default input buffer size of at least 4096 bytes.
268+
Unless the client explicitly requests a different input buffer size for the
269+
channel, it MAY assume that 4096 bytes can be borrowed before the first
270+
:program:`exec add-credit` response.
271+
222272
kill
223273
====
224274

@@ -338,12 +388,21 @@ exec request
338388
"opts": {},
339389
"channels": []
340390
},
341-
"flags": 3
391+
"flags": 11
342392
}
343393
344394
exec responses
345395
--------------
346396

397+
.. code:: json
398+
399+
{
400+
"type": "add-credit",
401+
"channels": {
402+
"stdin": 4096
403+
}
404+
}
405+
347406
.. code:: json
348407
349408
{

spell.en.pws

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,3 +494,4 @@ chu
494494
unsatisfiable
495495
cgroup
496496
procs
497+
unencoded

0 commit comments

Comments
 (0)