From ce4e07f6a4d89b9ad660775cf404d2a94a79f091 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Fri, 13 Dec 2013 13:39:28 +0100 Subject: [PATCH] Added comments about optimizations that may be included as part of fixing 423974 - Optimize flow control. --- .../main/java/org/eclipse/jetty/spdy/Flusher.java | 10 ++++++++++ .../org/eclipse/jetty/spdy/StandardSession.java | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Flusher.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Flusher.java index d5838a95be4..0be5f941d12 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Flusher.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Flusher.java @@ -203,6 +203,16 @@ public class Flusher if (controller != null) controller.write(flusherCB, buffers); + + // TODO: optimization + // If the callback completely immediately, it means that + // the connection is not congested, and therefore we can + // write more data without blocking. + // Therefore we should check this condition and increase + // the write window, which means to things: autotune the + // MAX_GATHER parameter, and/or autotune the buffer returned + // by FrameBytes.getByteBuffer() (see also comment there). + return State.SCHEDULED; } diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java index 4c249e6d54a..5e51cbe6735 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java @@ -1163,6 +1163,20 @@ public class StandardSession implements ISession, Parser.Listener, Dumpable IStream stream = getStream(); int windowSize = stream.getWindowSize(); + // TODO: optimization + // Right now, we use the windowSize to chunk big buffers. + // However, if the window size is large, we may congest the + // connection, or favor one stream that does a big download, + // starving the other streams. + // Also, SPDY DATA frames have a maximum of 16 MiB size, which + // is not enforced here. + // We should have a configurable "preferredDataFrameSize" + // (or even better autotuning) that will allow to send chunks + // that will not starve other streams and small enough to + // not congest the connection, while avoiding to send too many + // TCP packets. + // See also comment in class Flusher. + size = dataInfo.available(); if (size > windowSize) size = windowSize;