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

Tommy Pauly <tpauly@apple.com> Sun, 12 November 2017 23:54 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 6756C1243F6 for <taps@ietfa.amsl.com>; Sun, 12 Nov 2017 15:54:09 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.301
X-Spam-Level:
X-Spam-Status: No, score=-4.301 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] 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 t2zG5QeacqLV for <taps@ietfa.amsl.com>; Sun, 12 Nov 2017 15:54:07 -0800 (PST)
Received: from mail-in1.asia.apple.com (mail-out.asia.apple.com [17.82.254.63]) (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 374DC1205F0 for <taps@ietf.org>; Sun, 12 Nov 2017 15:54:07 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1510530845; 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=WVg1xZCvvJgZEYswmZQsmH66sQlIcjlUtkdeuo0XfbQ=; b=HIuiiod0P+vPdWXxgAz+3jsMg4kZW3SnWPlmoGNHCRREHc42veWSMXP3fFLK/w2D nZpoCO3OlOsRN90kIC3kuqOS72QId0phIvI227wzkLMY9sxJkDqZVqIpllRBkgZ2 eIpdQ2OhfeCnEZ/yklqAWLDM+Y5buoz6YR9Ce+VHKmIMazHnTINE9m/A3YCWZgQz 3P//JQWgJlSKKoyeoBMiy13uMvin4psLtdMJukap36SdVS0S+LUMddpBFveX+DyF tGyoWqOx2EUx0UW2xWRrQLSlLNWe/phIAA+f/FWMDyOVD8bbzPhmkiaHdDtXVYUA 94V7k4fq1kYknZHGqlp+/A==;
Received: from relay2.asia.apple.com ( [17.82.200.16]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in1.asia.apple.com (Apple Singapore Mail Gateway) with SMTP id 2C.63.07591.D1FD80A5; Mon, 13 Nov 2017 07:54:05 +0800 (MYT)
X-AuditID: 1152fe11-8b3ff70000001da7-98-5a08df1df998
Received: from echium.asia.apple.com ( [17.84.80.65]) by relay2.asia.apple.com (Apple Singapore relay) with SMTP id 09.AC.31851.D1FD80A5; Mon, 13 Nov 2017 07:54:05 +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 <0OZB005UQX24LE50@echium.asia.apple.com>; Mon, 13 Nov 2017 07:54:05 +0800 (SGT)
Sender: tpauly@apple.com
From: Tommy Pauly <tpauly@apple.com>
In-reply-to: <4EF62BB5-7638-4C3D-98A6-F1F081ABF216@ifi.uio.no>
Date: Mon, 13 Nov 2017 07:54:04 +0800
Cc: "taps@ietf.org" <taps@ietf.org>
Content-transfer-encoding: quoted-printable
Message-id: <98F9BFDF-0343-4846-A0F8-F3AF60168B5A@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>
To: Michael Welzl <michawe@ifi.uio.no>
X-Mailer: Apple Mail (2.3445.5.5)
X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRmVeSWpSXmKPExsUiGHRCQFf2PkeUwf9X0hY/zu5ktbgT48Dk sWTJTyaP1asfMgcwRXHZpKTmZJalFunbJXBlbOxLL3goXfHuzgLGBsYLYl2MnBwSAiYSry/9 ZQSxhQRWMkkc3J8DE9/d1AsV38goMWlxIojNKyAo8WPyPZYuRg4OZgF1iSlTcrsYuYBKPjFK tN4/yAYSFxaQkNi8B6xcWMBeYvOcJSwgNpuAisTxbxuYQUo4Bewkzr4Cm8IioCrRtz0UpIJZ QFni8axGFghbW+LJuwusEEttJL5/vsYOsWk/k0TflrfMIAkRATWJE8tXs0FcrCjxcFMXK0iR hEAHm8SavX/YJjAKz0Jy9SyEq2ch2bGAkXkVo3huYmaObmaeoV5icWaiXmJBQU6qXnJ+7iZG cFj/E9zBOHWh4SFGAQ5GJR5e4eMcUUKsiWXFlbmHGCU4mJVEeP2esUcJ8aYkVlalFuXHF5Xm pBYfYpTmYFES5+2L/BQpJJCeWJKanZpakFoEk2Xi4JRqYFwt6XJfslbt7hQRBRPJf9+Xfr1x xoX50/2q0ol7Z3UyquRv8Mtbf9OR6/RkGclZIkmzp578OenR3eD3LJ4cKoHpm1tnZUcWHDOY fv/QJcN10x5ZJk1Vem79RFKuyPVFdZ1i5otnbHtN3q/8sEN7X21bdF1Dy6a68Icn56xc8G/q ndsuzacPiN5QYinOSDTUYi4qTgQA5aNju2cCAAA=
X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLLMWRmVeSWpSXmKPExsUiGBLgqCt7nyPK4MZVYYsfZ3eyWtyJcWDy WLLkJ5PH6tUPmQOYorhsUlJzMstSi/TtErgyNvalFzyUrnh3ZwFjA+MFsS5GTg4JAROJ3U29 jCC2kMBGRolJixNBbF4BQYkfk++xdDFycDALqEtMmZLbxcgFVPKJUaL1/kE2kLiwgITE5j1g 5cIC9hKb5yxhAbHZBFQkjn/bwAxSwilgJ3H2FdgUFgFVib7toSAVzALKEo9nNbJA2NoST95d YIVYaiPx/fM1dohN+5kk+ra8ZQZJiAioSZxYvpoN4mJFiYebulgnMArMQnLoLIRDZyEZu4CR eRWjaFFqTmKlkV5icWaiXmJBQU6qXnJ+7iZGUCAGnRDYwTjrkMEhRgEORiUeXsbjHFFCrIll xZW5hxglOJiVRHj9nrFHCfGmJFZWpRblxxeV5qQWH2KU5mBREufVjPoUKSSQnliSmp2aWpBa BJNl4uCUamAUUklh9Pe7EFqjPuOqdmr5Ea81MlJ/IvMkTb/Kxje7ftnJLqTxTeFFMt8k5/2a E/1DFwVpfAoz6Pv1pa6J/UGFVn5E9s8qv+D9S1a5c9hONJoVckqWy//kssfbXfhWrDDz7mf9 wSex+o/1eZaVzwoct5/j3dcYkd0mzH5tn4P4/JvPDr+QDlRiKc5INNRiLipOBAB4lOLjQAIA AA==
Archived-At: <https://mailarchive.ietf.org/arch/msg/taps/oXlcLpw78B95qxRuH98bdM6jvTE>
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: Sun, 12 Nov 2017 23:54:09 -0000

The code I work with does TCP_NOTSENT_LOWAT by default, so we have a fair amount of experience with 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.

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.

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

Does that help clarify things?

Thanks,
Tommy

> On Nov 13, 2017, at 12:30 AM, Michael Welzl <michawe@ifi.uio.no> wrote:
> 
> Hi,
> 
> Another thought related to the post-sockets draft:
> 
> Post-sockets lets an application programmer define dependencies. That’s good, because dependencies exist, but it comes at the cost of complexity.
> My gut feeling tells me: if you have dependencies to take care of, it’s best to leave the data with the application and not hand it over to the transport at all until the last minute.
> 
> Controlling the buffer with something like TCP_NOTSENT_LOWAT would be a way for an application to only give the most recent, relevant data to the transport, and decide to throw away data on its own in case a preceding message was thrown away (which it might learn from transport).
> 
> I haven’t written code that uses TCP_NOTSENT_LOWAT myself, but I would guess that the trade-off in using this is: if you set this value low, you have more control over the buffer and can be more efficient in your decisions, but the disadvantage is that the transport permanently comes back to you and says “empty, empty, empty, ….” - which may be inconvenient / inefficient for the programmer.
> 
> If I’m right with all my musings here, then for an application that has block dependencies, the design should depend on what is easier to handle: defining priorities towards the transport layer on one side, or dealing with the transport calling us quickly all the time because its buffer is about to run empty, plus handling dependencies in the application on the other.
> 
> I don’t know - which one IS easier?
> 
> I’d love to see this discussed a little, and I’d also love to know if my interpretation of the trade-off in this email is even correct.
> 
> Cheers,
> Michael
> 
> _______________________________________________
> Taps mailing list
> Taps@ietf.org
> https://www.ietf.org/mailman/listinfo/taps