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

Tommy Pauly <tpauly@apple.com> Mon, 13 November 2017 02:36 UTC

Return-Path: <tpauly@apple.com>
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 65A091289B5 for <taps@ietfa.amsl.com>; Sun, 12 Nov 2017 18:36:57 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.3
X-Spam-Level:
X-Spam-Status: No, score=-4.3 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=apple.com
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 vOYaAAYiJF1E for <taps@ietfa.amsl.com>; Sun, 12 Nov 2017 18:36:55 -0800 (PST)
Received: from mail-in2.asia.apple.com (mail-out.asia.apple.com [17.82.254.64]) (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 87F8C128B37 for <taps@ietf.org>; Sun, 12 Nov 2017 18:36:31 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1510540588; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1ymtv+j7hBOueafn+Rf/dHLmR9GIkHtD40kS/7USOls=; b=gwOxVBCWbXj4aF3wA4jZdQto9PPfOTwe4bdiePBEE1v+oup35/EKAit/eA9KCskI Bh0xX4dyGj9/DzSL9lGEPB9pkpu/xpOdamy3HvsYRWJLo9c9+1xptL9g0p5fx4iZ kZtyPdhWFissiyljyQilcnq85K6yfDhJLi0paHND/UDfACHzsUdayCeXvfSXqODs z1gcBSD1sU6nlcUqO2ted3Z0wsynCqkBRwrpqB7uRRC86OJ8HOoblPZPgQuvFKen jUg/FhfsHmLSz7AWCIkU3UJNT+Ahk5T4seXQ3g+PG3Bitr7Txsfc12K6Tdxj9Ail cruEPYMyq2luQl+TDo7QoQ==;
Received: from relay1.asia.apple.com ( [17.82.200.18]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in2.asia.apple.com (Apple Singapore Mail Gateway) with SMTP id 62.1A.05091.C25090A5; Mon, 13 Nov 2017 10:36:28 +0800 (MYT)
X-AuditID: 1152fe06-a100e9c0000013e3-90-5a09052cdb39
Received: from echium.asia.apple.com ( [17.84.80.65]) by relay1.asia.apple.com (Apple Singapore relay) with SMTP id 23.0F.23340.C25090A5; Mon, 13 Nov 2017 10:36:28 +0800 (MYT)
MIME-version: 1.0
Content-type: text/plain; charset="utf-8"
Received: from [17.235.154.204] by echium.asia.apple.com (Oracle Communications Messaging Server 8.0.1.3.20170825 64bit (built Aug 25 2017)) with ESMTPSA id <0OZC002864KSFL00@echium.asia.apple.com>; Mon, 13 Nov 2017 10:36:28 +0800 (SGT)
Sender: tpauly@apple.com
From: Tommy Pauly <tpauly@apple.com>
In-reply-to: <D64CF7F6-D8BB-497E-8AAA-6F9A6B86E321@ifi.uio.no>
Date: Mon, 13 Nov 2017 10:36:27 +0800
Cc: "taps@ietf.org" <taps@ietf.org>
Content-transfer-encoding: quoted-printable
Message-id: <1EC37784-46F1-4E35-93D7-A63413277C61@apple.com>
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>
To: Michael Welzl <michawe@ifi.uio.no>
X-Mailer: Apple Mail (2.3445.5.5)
X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBLMWRmVeSWpSXmKPExsUiGHRCSFeHlTPK4HmbpsWPsztZLe7EODB5 LFnyk8lj9eqHzAFMUVw2Kak5mWWpRfp2CVwZ3fNOMxZ0yFUcbP7I1MC4XKKLkZNDQsBE4taU T4xdjFwcQgIrmSQaF3xkgUksfTuBFSKxkVHi3rJ77CAJXgFBiR+T7wEVcXAwC6hLTJmSC1Hz iVGi8UMLE0hcWEBCYvOeRJByYQF7ic1zloDNZBNQkTj+bQMziM0pYCdxqOEhG0g5i4CqxJuJ CSBhZgFlicezGlkgbG2JJ+8usEJstZHYOPkW1DnLmCVWffnBBJIQEVCTOLF8NRvEzYoSDzd1 gRVJCPSwSSzb8IF1AqPwLCRnz0I4exaSHQsYmVcxiucmZuboZuYZ6SUWZybqJRYU5KTqJefn bmIEh/c/th2MC14bHmIU4GBU4uGd+IYjSog1say4MvcQowQHs5II75H7QCHelMTKqtSi/Pii 0pzU4kOM0hwsSuK8vZGfIoUE0hNLUrNTUwtSi2CyTBycUg2MyqnxnYcsVshcLW7bvOex9+8J SzYZ/cthzrjUa/hhl5J31I5l4VpO8XHhSr1qzicWPZmyo1VTVn5LkpPqrw+Nz4QseapWC1w4 Z6h/enWus/i1L7yaLqujbxdEdPB2+rycuqie1z2n2bb7Nz/3mpKTmxyWPd8x9bXHvjjfJ6vb 7z2dv1l3gdY/JZbijERDLeai4kQAHhMj8WsCAAA=
X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrALMWRmVeSWpSXmKPExsUiGBLgqKvDyhllsGujssWPsztZLe7EODB5 LFnyk8lj9eqHzAFMUVw2Kak5mWWpRfp2CVwZ3fNOMxZ0yFUcbP7I1MC4XKKLkZNDQsBEYunb CaxdjFwcQgIbGSXuLbvHDpLgFRCU+DH5HksXIwcHs4C6xJQpuRA1nxglGj+0MIHEhQUkJDbv SQQpFxawl9g8ZwkLiM0moCJx/NsGZhCbU8BO4lDDQzaQchYBVYk3ExNAwswCyhKPZzWyQNja Ek/eXWCF2GojsXHyLahzljFLrPrygwkkISKgJnFi+Wo2iJsVJR5u6mKdwCgwC8mlsxAunYVk 7AJG5lWMokWpOYmVhnqJxZmJeokFBTmpesn5uZsYQeEYdEJoB+PH/QaHGAU4GJV4eJe84YgS Yk0sK67MPcQowcGsJMJ75D5QiDclsbIqtSg/vqg0J7X4EKM0B4uSOK9m1KdIIYH0xJLU7NTU gtQimCwTB6dUA+Ok6cET13Vw7cwyuR3P2q9ea+/Hw36i+c2+BUr/fa+Er7u/qmXHss/zZ6W8 tmvIPHWqJ9eP503qzl2pRW8zH5wNXN23rOp2nY2Ruhj3WuXLpwOdv6hKVD2Mti1MdHtlZRsw Zf7lV3tNV21cwi5U8vY8b5HZyahzvW4CZ5S8difPnrWP1X2TI68SS3FGoqEWc1FxIgBgXTZm QwIAAA==
Archived-At: <https://mailarchive.ietf.org/arch/msg/taps/0vF3vzOrvUbAbwD950TFVLCDgbI>
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 02:36:57 -0000


> 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.
> 
> 
>> 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.

> 
> I guess additionally offering to describe dependencies doesn’t hurt anyway, btw … what made me worried about the complexity is the possibility that these dependencies would change over time, and then the application would want to send an update to post-sockets.  I guess the easy way out is not to offer such dynamics (as indeed in this case an application might be better off handling it in the way I describe above?).
> 
> Cheers,
> Michael
> 
> _______________________________________________
> Taps mailing list
> Taps@ietf.org
> https://www.ietf.org/mailman/listinfo/taps