Re: [aqm] avoiding the sqrt

Andrew Mcgregor <andrewmcgr@google.com> Tue, 18 August 2015 23:26 UTC

Return-Path: <andrewmcgr@google.com>
X-Original-To: aqm@ietfa.amsl.com
Delivered-To: aqm@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 55FFA1A88C1 for <aqm@ietfa.amsl.com>; Tue, 18 Aug 2015 16:26:41 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 2.046
X-Spam-Level: **
X-Spam-Status: No, score=2.046 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FM_FORGED_GMAIL=0.622, FRT_FUCK2=3.434, HTML_MESSAGE=0.001, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=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 kmg6QXj8NBJR for <aqm@ietfa.amsl.com>; Tue, 18 Aug 2015 16:26:39 -0700 (PDT)
Received: from mail-lb0-x234.google.com (mail-lb0-x234.google.com [IPv6:2a00:1450:4010:c04::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id D37071A889C for <aqm@ietf.org>; Tue, 18 Aug 2015 16:26:37 -0700 (PDT)
Received: by lbcbn3 with SMTP id bn3so112568537lbc.2 for <aqm@ietf.org>; Tue, 18 Aug 2015 16:26:36 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=RIocjbQK3SQsKoK2usbyspOH9sll1kSlmglm3bkB7ts=; b=AVigGojKDwvi7ZnnbnGj0Aavycei+AIAw9xRISVXz7vj3NCpAZ58jH8NGEtHzuiQ8E 4nsEsIYYWj3XQygkJPTodwavRGsCUPK/zKvUfr3IoZ0aLxs4giRET18TGFLqJSy3nXHf B6kK2WOTkPrKiBywnDFXvNp/SNv0NRMur/3p3jsRetO43zGxkU456keXE4ATrzNedDdl SOSnmcRtmsjHLo7LdTVUy8gDK/UM1oqoVEOpj7fsx7pROZN9w16zkjJPL3eoO5fboJXt Jv44H3cZ79WGb3NX77+xwtvSH86WoQ/QNPISwJCsQS32TELEt8C90gsfs8EdscfV6wHN Slnw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=RIocjbQK3SQsKoK2usbyspOH9sll1kSlmglm3bkB7ts=; b=bSg+P/uXKIhnd5fAYOVetzxtMY94cSPoJhjhxuGS7XoOchmjRrN2+EzJXNIusIgcg4 elxXKndQaZXEs+TGLLGzSj9guTBXyD3jrEkSjc0fq2UddWNnsOp4qmEPVobv7I9h1Gun pkfNIl6ILpwYjTOpQr0oaL8Uo3+c8v8AWStJipvv5YpbsB/4bI/IzKMNahALUi2QkMwW APsnT5ezlJsC42FNbcTAxW1WnALOzVUoi9Sy7I15xaVu/CyDJ4nPbLtCpm8t0G35a8gV 9LbFyLVjSFPKhSu7Khoj9wvJyJBg+F/rMrsT9IZRKWM+9K2p+wbURdYXu5EFxVIUc4Jr cVYw==
X-Gm-Message-State: ALoCoQlQfn5YV4hfg8jbsEbu5b7SMhobmOFRiusNALpQYDdfjlW8XfTrpbqLyFYiXexchpPvcY0u
MIME-Version: 1.0
X-Received: by 10.112.132.1 with SMTP id oq1mr4339358lbb.81.1439940396279; Tue, 18 Aug 2015 16:26:36 -0700 (PDT)
Received: by 10.114.79.34 with HTTP; Tue, 18 Aug 2015 16:26:36 -0700 (PDT)
In-Reply-To: <274D3A0FA900FD47AA6B56991AAA32FDC53BB02B@wtl-exchp-1.sandvine.com>
References: <274D3A0FA900FD47AA6B56991AAA32FDC53BAA3F@wtl-exchp-1.sandvine.com> <7A2801D5E40DD64A85E38DF22117852C70AF58FE@wdc1exchmbxp05.hq.corp.viasat.com> <274D3A0FA900FD47AA6B56991AAA32FDC53BB02B@wtl-exchp-1.sandvine.com>
Date: Wed, 19 Aug 2015 09:26:36 +1000
Message-ID: <CAPRuP3nT6vnmSK9oCyGbVDAPfjuQKKnt_cHKKydHKsAL0DgYow@mail.gmail.com>
From: Andrew Mcgregor <andrewmcgr@google.com>
To: Jeff Weeks <jweeks@sandvine.com>
Content-Type: multipart/alternative; boundary="047d7b3a837cd1b7df051d9e3ff6"
Archived-At: <http://mailarchive.ietf.org/arch/msg/aqm/JC-0Ckz1bQm40aa4jQOScLS9cfs>
Cc: "Agarwal, Anil" <Anil.Agarwal@viasat.com>, "aqm@ietf.org" <aqm@ietf.org>
Subject: Re: [aqm] avoiding the sqrt
X-BeenThere: aqm@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "Discussion list for active queue management and flow isolation." <aqm.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/aqm>, <mailto:aqm-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/aqm/>
List-Post: <mailto:aqm@ietf.org>
List-Help: <mailto:aqm-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/aqm>, <mailto:aqm-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 18 Aug 2015 23:26:41 -0000

Memory access on modern CPUs is astonishingly expensive as well, so the
pendulum is well over on the 'just calculate it' side; only in very low-end
embedded devices would there be any benefit to a lookup table (for
perspective, a Raspberry Pi probably loses from the lookup table, and
that's a $35 device; the common MIPS chips found in home routers are very
likely about even on the two approaches, although I admit I have not
benchmarked them).  The reasons to do tables these days are 1) if the
calculation would touch a lot more memory (for example, Minstrel rate table
construction) or 2) if it is very hard to do accurately in integer
arithmetic (Jonathan's case here).

On 11 August 2015 at 23:05, Jeff Weeks <jweeks@sandvine.com> wrote:

> Indeed, the microsec granularity means the lookup table would be quite
> large, or would need to use a reduced index into a smaller table.
> After looking at modern cycle counts for integer multiply, I'm realizing
> that they're not nearly as expensive as I remember them to be, so the Linux
> implementation's approach is likely more efficient.
>
> --Jeff
> ________________________________________
> From: Agarwal, Anil [Anil.Agarwal@viasat.com]
> Sent: Monday, August 10, 2015 2:38 PM
> To: Jeff Weeks; aqm@ietf.org
> Subject: RE: avoiding the sqrt
>
> Jeff,
>
> Did you mean -
>     pre-calculate a set of interval/sqrt(count) for some range of count
> --  probably (1..interval^2),
>     and for any count > interval^2, the next interval can just be set to
> t+1
>
> Also, interval is generally kept in microseconds, hence a nominal value
> for interval is 100000.
>
> The current Codel Linux implementation of 1/sqrt(count) uses 4
> multiplications.
>
> Anil
>
> -----Original Message-----
> From: aqm [mailto:aqm-bounces@ietf.org] On Behalf Of Jeff Weeks
> Sent: Monday, August 10, 2015 12:18 PM
> To: aqm@ietf.org
> Subject: [aqm] avoiding the sqrt
>
> The CoDel control_law is defined as 't + interval/sqrt(count)'
>
> The sample implementation (
> https://urldefense.proofpoint.com/v2/url?u=http-3A__queue.acm.org_appendices_codel.html&d=BQICAg&c=jcv3orpCsv7C4ly8-ubDob57ycZ4jvhoYZNDBA06fPk&r=FyvaklKYrHaSCPjbBTdviWIW9uSbnxdNSheSGz1Jvq4&m=Mwm2-08h6DG8dG8A8i_FAQ9gIL67_jeiZA_pVQpEnIU&s=dMb61gcX82gBDxDv3nIAN4_lJma52tJT57lEdcXrVko&e=
> ) suggests that sqrt(count) can be calculated using only integer
> multiplication, but I'm wondering if it even needs to be calculated.
>
> Would it not be more efficient to pre-calculate a set of 1/sqrt(count) for
> some range --  probably (1..interval), and for any count > interval, the
> next interval can just be set to t+1.
>
> Is there any reason to not use this approach (assuming sufficient memory
> exists, of course)?
>
> --Jeff
>
> ________________________________
> /dev/jeff_weeks.x2936
> Sandvine Incorporated
>
> _______________________________________________
> aqm mailing list
> aqm@ietf.org
>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.ietf.org_mailman_listinfo_aqm&d=BQICAg&c=jcv3orpCsv7C4ly8-ubDob57ycZ4jvhoYZNDBA06fPk&r=FyvaklKYrHaSCPjbBTdviWIW9uSbnxdNSheSGz1Jvq4&m=Mwm2-08h6DG8dG8A8i_FAQ9gIL67_jeiZA_pVQpEnIU&s=guSznYIkwKsTZpoAOLCaLdhlKa4GUMNrO7mu4sv3nMM&e=
>
> _______________________________________________
> aqm mailing list
> aqm@ietf.org
> https://www.ietf.org/mailman/listinfo/aqm
>



-- 
Andrew McGregor | SRE | andrewmcgr@google.com | +61 4 1071 2221