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

Jetty 12: Review SerializedInvoker.Link.getInvocationType() #10091

Closed
sbordet opened this issue Jul 10, 2023 · 4 comments
Closed

Jetty 12: Review SerializedInvoker.Link.getInvocationType() #10091

sbordet opened this issue Jul 10, 2023 · 4 comments
Assignees

Comments

@sbordet
Copy link
Contributor

sbordet commented Jul 10, 2023

Jetty version(s)
12

Description
SerializedInvoker.Link.getInvocationType() currently returns hardcoded BLOCKING.
This is because a blocking task can be offered while a non-blocking one is running, so the thread running the non-blocking task may assume that the task currently running is non-blocking, but then executes a blocking one that was offered concurrently.

This strategy works, but assumes the worst case, which may result in unnecessary threads hand-overs, for example for HTTP/2 DATA frames, where an application could pass a NON_BLOCKING Runnable to Request.demand(Runnable).

Review whether we can improve on this logic, possibly having the thread offering the blocking task wait until previous non-blocking tasks are run.

@gregw
Copy link
Contributor

gregw commented Aug 23, 2023

If we change the AtomicReference to the tail a AtomicMarkableReference then the mark can indicate if the task returned from offer was blocking or not.

So we have 6 possible states when we offer a task (blocking or non_blocking (ignoring either for now)) to a serializer that is either empty, contains all non_blocking, or contains at least 1 blocking.

Tail Offer Blocking Offer Non-Blocking
Empty return Blocking Link with Q marked Blocking return Non-Blocking Link with Q marked Non-Blocking
Blocking return null return null
Non-Blocking Add a new non-blocking Link to the Q, return a task that waits until task in Q in Q unblocks it an then it runs the task return null

@joakime
Copy link
Contributor

joakime commented Feb 21, 2024

See also #11425

@gregw
Copy link
Contributor

gregw commented Oct 2, 2024

See also #12266

@lorban
Copy link
Contributor

lorban commented Oct 30, 2024

#12395 tackles this.

@lorban lorban closed this as completed Nov 8, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Jetty 12.1.0 Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

No branches or pull requests

4 participants