Return-Path: <noreply@github.com>
X-Original-To: quic-issues@ietfa.amsl.com
Delivered-To: quic-issues@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1])
 by ietfa.amsl.com (Postfix) with ESMTP id 3AA723A22C4
 for <quic-issues@ietfa.amsl.com>; Mon, 13 Apr 2020 18:32:47 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.267
X-Spam-Level: 
X-Spam-Status: No, score=-3.267 tagged_above=-999 required=5
 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.168, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 HTML_MESSAGE=0.001, MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key)
 header.d=github.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 50TuTp89bMtj for <quic-issues@ietfa.amsl.com>;
 Mon, 13 Apr 2020 18:32:45 -0700 (PDT)
Received: from out-19.smtp.github.com (out-19.smtp.github.com [192.30.252.202])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by ietfa.amsl.com (Postfix) with ESMTPS id 8FA113A22C2
 for <quic-issues@ietf.org>; Mon, 13 Apr 2020 18:32:45 -0700 (PDT)
Received: from github-lowworker-bb778fb.ash1-iad.github.net
 (github-lowworker-bb778fb.ash1-iad.github.net [10.56.102.56])
 by smtp.github.com (Postfix) with ESMTP id A4126520357
 for <quic-issues@ietf.org>; Mon, 13 Apr 2020 18:32:44 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com;
 s=pf2014; t=1586827964;
 bh=ppO0mQ7KLrxiH48emjp8TCIBrv3VYNWLT+qIXBKCLhA=;
 h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:List-ID:
 List-Archive:List-Post:List-Unsubscribe:From;
 b=wGKbjJg8fjlWJeaUOEp5tOtmGRk9Oi1PS9nDZH3Cn25wsNb7wjpjCqTw41qjmUdkA
 Fgxk1fTwReiMPSfj3zJhsjrUWKRwq/tkbchFmn3lOVgEPFPY57lbxVbW59DxjnpoiZ
 gMJ38j7qORX5ON1LcxHiLOKjg3owzYma0VpgZw5I=
Date: Mon, 13 Apr 2020 18:32:44 -0700
From: Martin Thomson <notifications@github.com>
Reply-To: quicwg/base-drafts
 <reply+AFTOJK2UFNIYREP44DYADXF4UDZ3ZEVBNHHCHNWTMM@reply.github.com>
To: quicwg/base-drafts <base-drafts@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Message-ID: <quicwg/base-drafts/pull/3577/review/392540915@github.com>
In-Reply-To: <quicwg/base-drafts/pull/3577@github.com>
References: <quicwg/base-drafts/pull/3577@github.com>
Subject: Re: [quicwg/base-drafts] [qpack] Overhaul the pseudocode (#3577)
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="--==_mimepart_5e9512bc94814_68f13fbdd22cd95c1710b2";
 charset=UTF-8
Content-Transfer-Encoding: 7bit
Precedence: list
X-GitHub-Sender: martinthomson
X-GitHub-Recipient: quic-issues
X-GitHub-Reason: subscribed
X-Auto-Response-Suppress: All
X-GitHub-Recipient-Address: quic-issues@ietf.org
Archived-At: <https://mailarchive.ietf.org/arch/msg/quic-issues/meeH0I2dihb8qxALBqU0N3vXu5s>
X-BeenThere: quic-issues@ietf.org
X-Mailman-Version: 2.1.29
List-Id: Notification list for GitHub issues related to the QUIC WG
 <quic-issues.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/quic-issues>,
 <mailto:quic-issues-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/quic-issues/>
List-Post: <mailto:quic-issues@ietf.org>
List-Help: <mailto:quic-issues-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/quic-issues>,
 <mailto:quic-issues-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 14 Apr 2020 01:32:47 -0000


----==_mimepart_5e9512bc94814_68f13fbdd22cd95c1710b2
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

@martinthomson commented on this pull request.

I couldn't see any problems, but I have some suggestions.

Thanks for doing the cleanup.

>  for header in headers:
-  staticIdx = staticTable.getIndex(header)
-  if staticIdx:
-    encodeIndexReference(streamBuffer, staticIdx)
+  staticIndex = staticTable.getIndex(header)

```suggestion
  staticIndex = staticTable.findIndex(header)
```

This is a search, right?

>      continue
 
-  dynamicIdx = dynamicTable.getIndex(header)
-  if !dynamicIdx:
+  dynamicIndex = dynamicTable.getIndex(header)

```suggestion
  dynamicIndex = dynamicTable.findIndex(header)
```

>      # No matching entry.  Either insert+index or encode literal
-    nameIdx = getNameIndex(header)
+
+    # getNameIndex attempts to find an index for this header's name.
+    # If one exists, it returns the name's (absolute) index and a
+    # boolean indicating which table has the name.  If the name
+    # can't be found, nameIndex is None
+    nameIndex, isStaticName = getNameIndex(header.name)

This is a little strange, as you are relying on functions on the tables to find the full entry, but you jump to a different approach for looking up the name.  I realize that two lookups are worse than one, but it's an odd stylistic jump, that's all.

```python
# An alternative might be to do the name lookup like this:
staticNameIndex = staticTable.findName(header.name)
if staticNameIndex is None:
    dynamicNameIndex = dynamicTable.findName(header.name)
if header.canIndex() and dynamicTable.canAdd(header):
    encodeInsert(encoderBuffer, staticNameIndex, dynamicNameIndex, header)
    dynamicIndex = dynamicTable.add(header)

    # For a bonus, continuing from the above, forget about the
    # newly inserted dynamic table entry if we are at the limit of blocked streams.
    if numBlockedStreams >= maxBlockedStreams:
        dynamicIndex = None
    else:
        addedBlockingEntry = True
        # Later, you can increase numBlockedStreams, but you only do that once.
```

>        dynamicTable.add(header)
-      dynamicIdx = dynamicTable.baseIndex
+      dynamicIndex = dynamicTable.getInsertCount()

I can't suggest here, but I think that you just want this:

```python
        dynamicIndex = dynamicTable.add(header)
```

Otherwise you are breaking encapsulation in a small way: relying on the insert count for getting the index of the thing you just added.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/3577#pullrequestreview-392540915
----==_mimepart_5e9512bc94814_68f13fbdd22cd95c1710b2
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p></p>=0D
<p><b>@martinthomson</b> commented on this pull request.</p>=0D
=0D
<p>I couldn't see any problems, but I have some suggestions.</p>=0D
<p>Thanks for doing the cleanup.</p><hr>=0D
=0D
<p>In <a href=3D"https://github.com/quicwg/base-drafts/pull/3577#discussi=
on_r407809660">draft-ietf-quic-qpack.md</a>:</p>=0D
<pre style=3D'color:#555'>&gt;  for header in headers:=0D
-  staticIdx =3D staticTable.getIndex(header)=0D
-  if staticIdx:=0D
-    encodeIndexReference(streamBuffer, staticIdx)=0D
+  staticIndex =3D staticTable.getIndex(header)=0D
</pre>=0D
=E2=AC=87=EF=B8=8F Suggested change=0D
<pre style=3D"color: #555">-  staticIndex =3D staticTable.getIndex(header=
)=0D
+  staticIndex =3D staticTable.findIndex(header)=0D
</pre>=0D
=0D
<p>This is a search, right?</p>=0D
=0D
<hr>=0D
=0D
<p>In <a href=3D"https://github.com/quicwg/base-drafts/pull/3577#discussi=
on_r407809694">draft-ietf-quic-qpack.md</a>:</p>=0D
<pre style=3D'color:#555'>&gt;      continue=0D
 =0D
-  dynamicIdx =3D dynamicTable.getIndex(header)=0D
-  if !dynamicIdx:=0D
+  dynamicIndex =3D dynamicTable.getIndex(header)=0D
</pre>=0D
=E2=AC=87=EF=B8=8F Suggested change=0D
<pre style=3D"color: #555">-  dynamicIndex =3D dynamicTable.getIndex(head=
er)=0D
+  dynamicIndex =3D dynamicTable.findIndex(header)=0D
</pre>=0D
=0D
=0D
<hr>=0D
=0D
<p>In <a href=3D"https://github.com/quicwg/base-drafts/pull/3577#discussi=
on_r407811268">draft-ietf-quic-qpack.md</a>:</p>=0D
<pre style=3D'color:#555'>&gt;      # No matching entry.  Either insert+i=
ndex or encode literal=0D
-    nameIdx =3D getNameIndex(header)=0D
+=0D
+    # getNameIndex attempts to find an index for this header&#39;s name.=
=0D
+    # If one exists, it returns the name&#39;s (absolute) index and a=0D=

+    # boolean indicating which table has the name.  If the name=0D
+    # can&#39;t be found, nameIndex is None=0D
+    nameIndex, isStaticName =3D getNameIndex(header.name)=0D
</pre>=0D
<p>This is a little strange, as you are relying on functions on the table=
s to find the full entry, but you jump to a different approach for lookin=
g up the name.  I realize that two lookups are worse than one, but it's a=
n odd stylistic jump, that's all.</p>=0D
<div class=3D"highlight highlight-source-python"><pre><span class=3D"pl-c=
"><span class=3D"pl-c">#</span> An alternative might be to do the name lo=
okup like this:</span>=0D
staticNameIndex <span class=3D"pl-k">=3D</span> staticTable.findName(head=
er.name)=0D
<span class=3D"pl-k">if</span> staticNameIndex <span class=3D"pl-k">is</s=
pan> <span class=3D"pl-c1">None</span>:=0D
    dynamicNameIndex <span class=3D"pl-k">=3D</span> dynamicTable.findNam=
e(header.name)=0D
<span class=3D"pl-k">if</span> header.canIndex() <span class=3D"pl-k">and=
</span> dynamicTable.canAdd(header):=0D
    encodeInsert(encoderBuffer, staticNameIndex, dynamicNameIndex, header=
)=0D
    dynamicIndex <span class=3D"pl-k">=3D</span> dynamicTable.add(header)=
=0D
=0D
    <span class=3D"pl-c"><span class=3D"pl-c">#</span> For a bonus, conti=
nuing from the above, forget about the</span>=0D
    <span class=3D"pl-c"><span class=3D"pl-c">#</span> newly inserted dyn=
amic table entry if we are at the limit of blocked streams.</span>=0D
    <span class=3D"pl-k">if</span> numBlockedStreams <span class=3D"pl-k"=
>&gt;=3D</span> maxBlockedStreams:=0D
        dynamicIndex <span class=3D"pl-k">=3D</span> <span class=3D"pl-c1=
">None</span>=0D
    <span class=3D"pl-k">else</span>:=0D
        addedBlockingEntry <span class=3D"pl-k">=3D</span> <span class=3D=
"pl-c1">True</span>=0D
        <span class=3D"pl-c"><span class=3D"pl-c">#</span> Later, you can=
 increase numBlockedStreams, but you only do that once.</span></pre></div=
>=0D
=0D
<hr>=0D
=0D
<p>In <a href=3D"https://github.com/quicwg/base-drafts/pull/3577#discussi=
on_r407813105">draft-ietf-quic-qpack.md</a>:</p>=0D
<pre style=3D'color:#555'>&gt;        dynamicTable.add(header)=0D
-      dynamicIdx =3D dynamicTable.baseIndex=0D
+      dynamicIndex =3D dynamicTable.getInsertCount()=0D
</pre>=0D
<p>I can't suggest here, but I think that you just want this:</p>=0D
<div class=3D"highlight highlight-source-python"><pre>        dynamicInde=
x <span class=3D"pl-k">=3D</span> dynamicTable.add(header)</pre></div>=0D=

<p>Otherwise you are breaking encapsulation in a small way: relying on th=
e insert count for getting the index of the thing you just added.</p>=0D
=0D
<p style=3D"font-size:small;-webkit-text-size-adjust:none;color:#666;">&m=
dash;<br />You are receiving this because you are subscribed to this thre=
ad.<br />Reply to this email directly, <a href=3D"https://github.com/quic=
wg/base-drafts/pull/3577#pullrequestreview-392540915">view it on GitHub</=
a>, or <a href=3D"https://github.com/notifications/unsubscribe-auth/AFTOJ=
K5CFAB2X4SIE35JASTRMO4LZANCNFSM4MHJICCQ">unsubscribe</a>.<img src=3D"http=
s://github.com/notifications/beacon/AFTOJK5U5VSN6XO6NW5F5CLRMO4LZA5CNFSM4=
MHJICC2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZ=
GOC5S3F4Y.gif" height=3D"1" width=3D"1" alt=3D"" /></p>=0D
<script type=3D"application/ld+json">[=0D
{=0D
"@context": "http://schema.org",=0D
"@type": "EmailMessage",=0D
"potentialAction": {=0D
"@type": "ViewAction",=0D
"target": "https://github.com/quicwg/base-drafts/pull/3577#pullrequestrev=
iew-392540915",=0D
"url": "https://github.com/quicwg/base-drafts/pull/3577#pullrequestreview=
-392540915",=0D
"name": "View Pull Request"=0D
},=0D
"description": "View this Pull Request on GitHub",=0D
"publisher": {=0D
"@type": "Organization",=0D
"name": "GitHub",=0D
"url": "https://github.com"=0D
}=0D
}=0D
]</script>=

----==_mimepart_5e9512bc94814_68f13fbdd22cd95c1710b2--

