Re: [Taps] API design: dependencies or buffer control?

Michael Welzl <michawe@ifi.uio.no> Mon, 13 November 2017 10:15 UTC

Return-Path: <michawe@ifi.uio.no>
X-Original-To: taps@ietfa.amsl.com
Delivered-To: taps@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 0EF00129485 for <taps@ietfa.amsl.com>; Mon, 13 Nov 2017 02:15:53 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.2
X-Spam-Level:
X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YNKzg_KV81Wi for <taps@ietfa.amsl.com>; Mon, 13 Nov 2017 02:15:51 -0800 (PST)
Received: from mail-out01.uio.no (mail-out01.uio.no [IPv6:2001:700:100:10::50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 12771124BE8 for <taps@ietf.org>; Mon, 13 Nov 2017 02:15:50 -0800 (PST)
Received: from mail-mx06.uio.no ([129.240.10.40]) by mail-out01.uio.no with esmtp (Exim 4.82_1-5b7a7c0-XX) (envelope-from <michawe@ifi.uio.no>) id 1eEBmP-0002p0-3t for taps@ietf.org; Mon, 13 Nov 2017 11:15:49 +0100
Received: from dhcp-82c4.meeting.ietf.org ([31.133.130.196]) by mail-mx06.uio.no with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) user michawe (Exim 4.82_1-5b7a7c0-XX) (envelope-from <michawe@ifi.uio.no>) id 1eEBmD-00078O-86; Mon, 13 Nov 2017 11:15:49 +0100
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\))
From: Michael Welzl <michawe@ifi.uio.no>
In-Reply-To: <1EC37784-46F1-4E35-93D7-A63413277C61@apple.com>
Date: Mon, 13 Nov 2017 18:15:32 +0800
Cc: "taps@ietf.org" <taps@ietf.org>
Content-Transfer-Encoding: quoted-printable
Message-Id: <38E6A4C0-14E2-4DBA-BFDF-6C16CD058B04@ifi.uio.no>
References: <CF0546DA-422B-4AA3-A593-1BC133AD730D@ifi.uio.no> <A19AC4F5-1A56-4F9B-A5C2-3643CD57FBC1@apple.com> <7F6D4FB0-3D41-4E06-BD11-54D897FA5345@ifi.uio.no> <3702C080-9EEA-441C-96C3-5A2A1FCC7ABA@apple.com> <B543F7E4-2327-4CAE-8707-0F61BE6DD655@ifi.uio.no> <4EF62BB5-7638-4C3D-98A6-F1F081ABF216@ifi.uio.no> <98F9BFDF-0343-4846-A0F8-F3AF60168B5A@apple.com> <D64CF7F6-D8BB-497E-8AAA-6F9A6B86E321@ifi.uio.no> <1EC37784-46F1-4E35-93D7-A63413277C61@apple.com>
To: Tommy Pauly <tpauly@apple.com>
X-Mailer: Apple Mail (2.3273)
X-UiO-SPF-Received: Received-SPF: neutral (mail-mx06.uio.no: 31.133.130.196 is neither permitted nor denied by domain of ifi.uio.no) client-ip=31.133.130.196; envelope-from=michawe@ifi.uio.no; helo=dhcp-82c4.meeting.ietf.org;
X-UiO-Spam-info: not spam, SpamAssassin (score=-4.9, required=5.0, autolearn=disabled, AWL=0.056, UIO_MAIL_IS_INTERNAL=-5, uiobl=NO, uiouri=NO)
X-UiO-Scanned: 85E9734BF1F42B0F9DA50A685C0495004AD1A3FF
Archived-At: <https://mailarchive.ietf.org/arch/msg/taps/yL1QWyXu2z8cf74sBD__XygpGyU>
Subject: Re: [Taps] API design: dependencies or buffer control?
X-BeenThere: taps@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: "IETF Transport Services \(TAPS\) Working Group" <taps.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/taps>, <mailto:taps-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/taps/>
List-Post: <mailto:taps@ietf.org>
List-Help: <mailto:taps-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/taps>, <mailto:taps-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 13 Nov 2017 10:15:53 -0000

Hi,

This is me trying to conclude this with a text proposal fort he draft, for the record and for the group - in line:


> On Nov 13, 2017, at 10:36 AM, Tommy Pauly <tpauly@apple.com> wrote:
> 
> 
> 
>> On Nov 13, 2017, at 10:08 AM, Michael Welzl <michawe@ifi.uio.no> wrote:
>> 
>> 
>>> On Nov 13, 2017, at 7:54 AM, Tommy Pauly <tpauly@apple.com> wrote:
>>> 
>>> The code I work with does TCP_NOTSENT_LOWAT by default, so we have a fair amount of experience with it.
>> 
>> I figured  :-)   AFAIK think Stuart invented it…
>> 
>> 
>>> If you're using sockets with TCP_NOTSENT_LOWAT, and you're doing asynchronous non-blocking socket operations, then you don't have the annoyance of getting these "empty" callbacks you're referring to—it just changes how aggressively the writable event fires, making it back off a bit.
>> 
>> Ah, ok, sure.
>> 
>> 
>>> With a Post-like API, having something directly like TCP_NOTSENT_LOWAT doesn't make much sense. Instead, the implementation may internally use that, but the equivalent application feedback is the completion that is returned based on the write messages. The timing of when the stack indicates when something has been written allows the application to understand the back-pressure properties of the transport, and if it able to generate or fetch data more slowly to match the back-pressure, it can. Otherwise, it can simply keep writing and the data will get enqueued within the library.
>> 
>> I mean, the way you describe it here, the application has no means to say how much it wants the layers below to buffer. I think that would be useful, no?
>> A big buffer is more convenient (based on the number write returns), a smaller buffer lets the application have control over the data until the last minute.
>> But then, doesn’t this amount to the same "nuisance vs. control of data until the last minute" trade-off that I described?
> 
> It can control exactly how much is buffered, since it knows when the data has been actually sent. If you never fail the enqueue of data into the API, you can put as much or as little into the buffer as you want. Since you don't just have a single "writable" callback from a socket, you actually get much more control.

Tommy and I talked in person; Tommy explained to me that the application knows about the state of the buffer below because it gets a callback whenever the post sockets system is sending something. This may mean a lot of callbacks, but I guess that isn’t a real problem. This sounds good to me - you don’t need to adjust the buffer this way, you just keep it small by waiting for a callback if you want - but then, the text in the post-sockets draft needs to be very clear about this procedure in my opinion.

Specifically, now there’s only this text in there:
***
   Carriers also
   provide .OnSent(), .OnAcked(), and .OnExpired() calls for binding
   default send event handlers to the Carrier, and .OnClosed() for
   handling passive close notifications.
***
… which should be expanded to explain exactly when these events are fired. So, OnSent fires whenever post sockets sends a message (and returns what? Any parameters?)
And FWIW, from this text, OnAck could be a transport layer event, which may not even be visible… when is this expected to fire?



>>> Dependencies between the messages that are being written, then, doesn't actually come into play much here. Dependencies are hints to the implementation and protocol stack of how to order work when scheduling to send (PRE-WRITE). TCP_NOTSENT_LOWAT or the completions to indicate that writes have completed are all about signaling back to the application to provide back-pressure (POST-WRITE).
>> 
>> I understand the functionality is separate, but you can achieve the same with it: from an application’s point of view, if I have blocks with dependencies and if you allow me to tune the buffer below the write call, then I can decide until the last minute that I’d rather not send a certain data block.
> 
> Since the app knows which blocks are outstanding, you can always wait to schedule the block, and you don't need to add dependencies. The dependencies are useful when you want to express that if there is internal re-ordering within a protocol, it can make sure that certain relationships between data are maintained.

Also for the record, from the conversation, we agree that:
- this is useful to have,
- but it should be static, i.e. not allowing the application to change dependencies it has once specified.

This should also be written in the draft.

Cheers,
Michael