mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DIRMINA-1095) Seems like the management f UDP sessions is really unneficient
Date Mon, 01 Oct 2018 15:22:00 GMT

    [ https://issues.apache.org/jira/browse/DIRMINA-1095?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16634190#comment-16634190

Emmanuel Lecharny commented on DIRMINA-1095:

If the selector is woken 5000 times per second, assuming all the keys are selected for write,
then the loop of sessions is going to be atrocious, and the flag will clearly make a difference.

Now, the time it will take to process many keys when the selector is awaken might also make
it possible that the next call will be for more keys, and so on. Up to a point,that would
stabilize, but we still don't want to process the loop over all the sessions in any case in

> Seems like the management f UDP sessions is really unneficient
> --------------------------------------------------------------
>                 Key: DIRMINA-1095
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-1095
>             Project: MINA
>          Issue Type: Improvement
>    Affects Versions: 2.0.19
>            Reporter: Emmanuel Lecharny
>            Priority: Major
>             Fix For: 2.0.20
> When we process incoming UDP messages, we iterate over the activated {{SelectionKey}}s.
That's ok, but for each one of them, we read the data and try to flush the scheduled messages.
The loop where it's done seems to iterate on *all* the managed sessions, for each keys we
are processing :
> {code:java}
>    private void processReadySessions(Set<SelectionKey> handles) {
>         Iterator<SelectionKey> iterator = handles.iterator();
>         while (iterator.hasNext()) {
>             SelectionKey key = iterator.next();
>             DatagramChannel handle = (DatagramChannel) key.channel();
>             iterator.remove();
>             try {
>                 if (key.isValid() && key.isReadable()) {
>                     readHandle(handle);
>                 }
>                 if (key.isValid() && key.isWritable()) {
>                     for (IoSession session : getManagedSessions().values()) {
>                         scheduleFlush((NioSession) session);
> ...
> {code}
> There is no reason to do so. First, we should not iterate on all the managed sessions
(we may have thousands), but only the sessions which have something to write, and we certainly
should not do that for every active key...

This message was sent by Atlassian JIRA

View raw message