-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[qpack] Overhaul the pseudocode #3577
Conversation
* Use the current terminology (insert count, base, encoder stream) * Update to current design (modulo encoding of RIC) * Normalize naming: index vs. idx * Comments Fixes #3544
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't see any problems, but I have some suggestions.
Thanks for doing the cleanup.
draft-ietf-quic-qpack.md
Outdated
staticIdx = staticTable.getIndex(header) | ||
if staticIdx: | ||
encodeIndexReference(streamBuffer, staticIdx) | ||
staticIndex = staticTable.getIndex(header) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
staticIndex = staticTable.getIndex(header) | |
staticIndex = staticTable.findIndex(header) |
This is a search, right?
draft-ietf-quic-qpack.md
Outdated
continue | ||
|
||
dynamicIdx = dynamicTable.getIndex(header) | ||
if !dynamicIdx: | ||
dynamicIndex = dynamicTable.getIndex(header) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dynamicIndex = dynamicTable.getIndex(header) | |
dynamicIndex = dynamicTable.findIndex(header) |
draft-ietf-quic-qpack.md
Outdated
# 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
# 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.
draft-ietf-quic-qpack.md
Outdated
dynamicTable.add(header) | ||
dynamicIdx = dynamicTable.baseIndex | ||
dynamicIndex = dynamicTable.getInsertCount() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't suggest here, but I think that you just want this:
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.
This pseudo code is much better! But I would like to support @martinthomson's comments, too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Your build errors are due to line-length; I think this should fix them.
draft-ietf-quic-qpack.md
Outdated
# getNameIndex attempts to find an index for this header's name. | ||
# If one exists, it returns the name's (absolute) index and a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# getNameIndex attempts to find an index for this header's name. | |
# If one exists, it returns the name's (absolute) index and a | |
# getNameIndex searches for this header's name in the table. | |
# If an entry matches, it returns the (absolute) index and a |
draft-ietf-quic-qpack.md
Outdated
if shouldIndex(header) and dynamicTable.canIndex(header): | ||
encodeLiteralWithIncrementalIndex(controlBuffer, nameIdx, | ||
header) | ||
encodeInsert(encoderBuffer, nameIndex, isStaticName, header) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encodeInsert(encoderBuffer, nameIndex, isStaticName, header) | |
encodeInsert( | |
encoderBuffer, nameIndex, isStaticName, header | |
) |
draft-ietf-quic-qpack.md
Outdated
wireRIC = | ||
(requiredInsertCount % (2 * getMaxEntries(maxTableCapacity))) + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wireRIC = | |
(requiredInsertCount % (2 * getMaxEntries(maxTableCapacity))) + 1; | |
wireRIC = ( | |
requiredInsertCount | |
% (2 * getMaxEntries(maxTableCapacity)) | |
) + 1 |
Fixes #3544