Discussion:
[jetty-users] Selector question
Josh Spiegel
2018-05-24 23:01:26 UTC
Permalink
Hi,

In the documentation ServerConnector, I see the following text:

<quote>
It is the selector thread that will call the Callback instances passed in
the EndPoint.fillInterested(Callback) or EndPoint.write(Callback,
java.nio.ByteBuffer...) methods. It is expected that these callbacks may do
some non-blocking IO work, but will always dispatch to the Executor service
any blocking, long running or application tasks.
</quote>

But I also found this blog that made it sound like maybe this is no longer
the case?
https://webtide.com/avoiding-parallel-slowdown-in-jetty-9/

Can anybody clarify? Specifically, I would like to know if onFillable()
will be run by a selector for ServerConnector/AbstractConnection. And if
not, is it ok to do blocking operations in onFillable()?

Thanks,
Josh
Joakim Erdfelt
2018-05-24 23:10:28 UTC
Permalink
Why do you need to know that?

The ManagedSelector behavior is controlled by the Threading Strategy.
Typically this is the EatWhatYouKill strategy.

Each task from a select() call is identified by the strategy for its
behavior, will it block? can it block? etc.
The Threading strategy also makes the call on if the task should execute,
invoke, or run.
The Threading strategy is also aware of the state of the ThreadPool when
making its decisions. (eg: behaviors change when the thread pool has few
idle threads left)

In short, by the time you are in the EndPoint, you can make no assumptions
about behavior at the selector / threading strategy / thread pool /
executor.
Post by Josh Spiegel
Hi,
<quote>
It is the selector thread that will call the Callback instances passed in
the EndPoint.fillInterested(Callback) or EndPoint.write(Callback,
java.nio.ByteBuffer...) methods. It is expected that these callbacks may do
some non-blocking IO work, but will always dispatch to the Executor service
any blocking, long running or application tasks.
</quote>
But I also found this blog that made it sound like maybe this is no longer
the case?
https://webtide.com/avoiding-parallel-slowdown-in-jetty-9/
Can anybody clarify? Specifically, I would like to know if onFillable()
will be run by a selector for ServerConnector/AbstractConnection. And if
not, is it ok to do blocking operations in onFillable()?
Thanks,
Josh
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Greg Wilkins
2018-05-25 05:48:17 UTC
Permalink
Josh,

that javadoc is indeed out of date.

We now allow Callback instances to use the Invocable interface to declare
if they are blocking or non-blocking, with blocking being assumed. So
there are no limits on what can be done... other than if a callback
declares itself to be non-blocking, then it should not block no linger too
long.

I will remove that old documentation.

cheers
Post by Josh Spiegel
Hi,
<quote>
It is the selector thread that will call the Callback instances passed in
the EndPoint.fillInterested(Callback) or EndPoint.write(Callback,
java.nio.ByteBuffer...) methods. It is expected that these callbacks may do
some non-blocking IO work, but will always dispatch to the Executor service
any blocking, long running or application tasks.
</quote>
But I also found this blog that made it sound like maybe this is no longer
the case?
https://webtide.com/avoiding-parallel-slowdown-in-jetty-9/
Can anybody clarify? Specifically, I would like to know if onFillable()
will be run by a selector for ServerConnector/AbstractConnection. And if
not, is it ok to do blocking operations in onFillable()?
Thanks,
Josh
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
--
Greg Wilkins <***@webtide.com> CTO http://webtide.com
Greg Wilkins
2018-05-25 06:01:53 UTC
Permalink
See commit e6e49bdc85
Post by Greg Wilkins
Josh,
that javadoc is indeed out of date.
We now allow Callback instances to use the Invocable interface to declare
if they are blocking or non-blocking, with blocking being assumed. So
there are no limits on what can be done... other than if a callback
declares itself to be non-blocking, then it should not block no linger too
long.
I will remove that old documentation.
cheers
Post by Josh Spiegel
Hi,
<quote>
It is the selector thread that will call the Callback instances passed in
the EndPoint.fillInterested(Callback) or EndPoint.write(Callback,
java.nio.ByteBuffer...) methods. It is expected that these callbacks may do
some non-blocking IO work, but will always dispatch to the Executor service
any blocking, long running or application tasks.
</quote>
But I also found this blog that made it sound like maybe this is no
longer the case?
https://webtide.com/avoiding-parallel-slowdown-in-jetty-9/
Can anybody clarify? Specifically, I would like to know if onFillable()
will be run by a selector for ServerConnector/AbstractConnection. And
if not, is it ok to do blocking operations in onFillable()?
Thanks,
Josh
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
--
--
Greg Wilkins <***@webtide.com> CTO http://webtide.com
Josh Spiegel
2018-05-25 15:02:46 UTC
Permalink
Greg/Joakim,

Makes sense - thank you for the quick response.

Josh
Post by Greg Wilkins
See commit e6e49bdc85
Post by Greg Wilkins
Josh,
that javadoc is indeed out of date.
We now allow Callback instances to use the Invocable interface to declare
if they are blocking or non-blocking, with blocking being assumed. So
there are no limits on what can be done... other than if a callback
declares itself to be non-blocking, then it should not block no linger too
long.
I will remove that old documentation.
cheers
Post by Josh Spiegel
Hi,
<quote>
It is the selector thread that will call the Callback instances passed
in the EndPoint.fillInterested(Callback) or EndPoint.write(Callback,
java.nio.ByteBuffer...) methods. It is expected that these callbacks may do
some non-blocking IO work, but will always dispatch to the Executor service
any blocking, long running or application tasks.
</quote>
But I also found this blog that made it sound like maybe this is no
longer the case?
https://webtide.com/avoiding-parallel-slowdown-in-jetty-9/
Can anybody clarify? Specifically, I would like to know if onFillable()
will be run by a selector for ServerConnector/AbstractConnection. And
if not, is it ok to do blocking operations in onFillable()?
Thanks,
Josh
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
--
--
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Continue reading on narkive:
Loading...