Skip to content
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

Define datagram backpressure control attributes #267

Merged
merged 5 commits into from
Jun 16, 2021

Conversation

yutakahirano
Copy link
Contributor

@yutakahirano yutakahirano commented May 18, 2021

Define the following attributes on DatagramDuplexStream.

  • incomingMaxAge
  • outgoingMaxAge
  • incomingHighWaterMark
  • outgoingHighWaterMark

Fixes #251, #221, #152


Preview | Diff

@yutakahirano
Copy link
Contributor Author

I made set(Incoming|Outgoing)HighWaterMark methods rather than members in WebTransportOptions because it'd be useful to set them multiple times, especially when the network condition changes.

@yutakahirano yutakahirano changed the title Define datagram control methods Define datagram backpressure control methods May 18, 2021
@yutakahirano
Copy link
Contributor Author

@jan-ivar @ricea can you take a look? Names may change based on the discussion at #251.

index.bs Outdated
Comment on lines 350 to 351
undefined setIncomingExpirationDuration(double ms);
undefined setOutgoingExpirationDuration(double ms);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look like simple setters, and should therefore be read-write attributes instead of methods, I claim. E.g. using latest naming from #251 (comment):

wt.datagrams.incomingMaxAge = 300; // ms
wt.datagrams.outgoingMaxAge = 800; // ms

I'm also wondering if we should take a cue from recent changes to bidirectional streams, and subclass readable and writable stream here, so we can push the attributes down:

wt.datagrams.readable.maxAge = 300; // ms
wt.datagrams.writable.maxAge = 800; // ms

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One concern is it can return null (when not set/the browser default behavior). Are you fine with the following IDL?

attribute double? incomingMaxAge;
attribute double? outgoingMaxAge;

I share the sentiment about subclassing with @ricea and I'd like to avoid that without a clear benefit. I'm not sure this is enough.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meeting:

  • Might be better to expose the implementation-defined default than return null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that the implementation-default value can be chosen for each receiveDatagram call when [[IncomingDatagramsExpirationDuration]]. So exposing a fixed value reduces the flexisibility. Ditto for the outgoing direction.

index.bs Outdated
Comment on lines 352 to 353
undefined setIncomingHighWaterMark(long highWaterMark);
undefined setOutgoingHighWaterMark(long highWaterMark);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it comes to highwaterMark, there's potential confusion with the same-named concept in the streams spec:

const stream = new WritableStream(
  { ... },
  new CountQueuingStrategy({ highWaterMark: 5 })
);

But I'm not 100% sure it's the same thing. That API I think is generally understood to be the buffer in the ReadableStream/WritableStream itself, distinct from its underlying source, whereas in our case, we have a setup at least on the writable side where we pre-fill the underlying sink's write-queue (for throughput and threading purposes), and what we really mean to control here is the depth of that write queue. But maybe this is a detail and that from the viewpoint of a producer (or consumer in the readable case) this is close enough to the the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They represent the same concept, the length of the queue in a stream. We have them in the underlying source and sink because removing stale chunks is not supported in general streams. Given that I think it's good to keep the same name. Web developers cannot control the buffer lengths in the streams, but instead they can control these values.

@yutakahirano yutakahirano force-pushed the yhirano/expiration-duration-methods branch from 91e61d7 to c67152f Compare June 3, 2021 10:13
@yutakahirano yutakahirano changed the title Define datagram backpressure control methods Define datagram backpressure control attributes Jun 3, 2021
@yutakahirano
Copy link
Contributor Author

I replaced the methods with attributes. PTAL again.

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
@jan-ivar jan-ivar added the Discuss at next meeting Flags an issue to be discussed at the next WG working label Jun 8, 2021
Copy link
Contributor

@ricea ricea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

index.bs Outdated Show resolved Hide resolved
@yutakahirano
Copy link
Contributor Author

@jan-ivar PTAL again.

I'm aware of #267 (comment) but I'd like to land this change soon. We can file another issue and discuss it there. If you don't like the possible breaking change, I can remove the getter part of incomingMaxAge and outgoingMaxAge.

@yutakahirano
Copy link
Contributor Author

Removing the "Discuss at next meeting" label as it is for the previous one.

@yutakahirano yutakahirano removed the Discuss at next meeting Flags an issue to be discussed at the next WG working label Jun 10, 2021
index.bs Outdated Show resolved Hide resolved
@yutakahirano
Copy link
Contributor Author

I'm going to land this change on Jun 16 (JST) if unless further comments are made.

@yutakahirano yutakahirano force-pushed the yhirano/expiration-duration-methods branch from 850b33a to 4c11ddc Compare June 16, 2021 04:59
@yutakahirano yutakahirano merged commit 809721b into main Jun 16, 2021
@yutakahirano yutakahirano deleted the yhirano/expiration-duration-methods branch June 16, 2021 05:01
github-actions bot added a commit that referenced this pull request Jun 16, 2021
SHA: 809721b
Reason: push, by @yutakahirano

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@wilaw wilaw mentioned this pull request Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add datagrams.setSendQueueExpiration(long duration)?
3 participants