diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-02-11 23:44:23 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-02-12 05:45:53 +0000 |
commit | 519fc4209460f28de8d4954c1a50402d4af6b02b (patch) | |
tree | 73551717ce2012235510b531d42d207bb5c7867d | |
parent | 93e7f6bcba5d8cbc0d9700ec64dc6540eb935ef2 (diff) |
Use small buffers where size matters more than speed.
10 files changed, 24 insertions, 8 deletions
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicator.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicator.java index 4441501da01..4eca82c81d2 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicator.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicator.java @@ -54,7 +54,8 @@ public class RPCCommunicator implements Communicator { private final int fleetControllerIndex; public static Supervisor createRealSupervisor() { - return new Supervisor(new Transport("rpc-communicator")); + return new Supervisor(new Transport("rpc-communicator")).enableSmallBuffers(); + } public RPCCommunicator(Supervisor supervisor, diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RpcServer.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RpcServer.java index 519f4c2d171..edaaca0605d 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RpcServer.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RpcServer.java @@ -99,7 +99,7 @@ public class RpcServer { disconnect(); log.log(Level.FINE, "Fleetcontroller " + fleetControllerIndex + ": Connecting RPC server."); if (supervisor != null) disconnect(); - supervisor = new Supervisor(new Transport("rpc" + port)); + supervisor = new Supervisor(new Transport("rpc" + port)).enableSmallBuffers(); addMethods(); log.log(Level.FINE, "Fleetcontroller " + fleetControllerIndex + ": Attempting to bind to port " + port); acceptor = supervisor.listen(new Spec(port)); diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ProxyServer.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ProxyServer.java index 4635ab4fd86..a9e4df087b0 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ProxyServer.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ProxyServer.java @@ -42,7 +42,7 @@ public class ProxyServer implements Runnable { private final static Logger log = Logger.getLogger(ProxyServer.class.getName()); private final AtomicBoolean signalCaught = new AtomicBoolean(false); - private final Supervisor supervisor = new Supervisor(new Transport("proxy-server", JRT_TRANSPORT_THREADS)); + private final Supervisor supervisor; private final ConfigProxyRpcServer rpcServer; private ConfigSourceSet configSource; @@ -56,6 +56,7 @@ public class ProxyServer implements Runnable { ProxyServer(Spec spec, ConfigSourceSet source, MemoryCache memoryCache, ConfigSourceClient configClient) { this.configSource = source; + supervisor = new Supervisor(new Transport("proxy-server", JRT_TRANSPORT_THREADS)).enableSmallBuffers(); log.log(Level.FINE, "Using config source '" + source); this.memoryCache = memoryCache; this.rpcServer = createRpcServer(spec); diff --git a/config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java b/config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java index 9aeb1c9da0f..4bfa2103cb1 100644 --- a/config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java +++ b/config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java @@ -39,7 +39,7 @@ public class JRTConnectionPool implements ConnectionPool { private volatile JRTConnection currentConnection; public JRTConnectionPool(ConfigSourceSet sourceSet) { - supervisor = new Supervisor(new Transport("config-jrtpool-" + sourceSet.hashCode())); + supervisor = new Supervisor(new Transport("config-jrtpool-" + sourceSet.hashCode())).enableSmallBuffers(); addSources(sourceSet); } diff --git a/container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.java b/container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.java index a30bcaa82e1..e16f873e001 100644 --- a/container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.java +++ b/container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.java @@ -155,7 +155,7 @@ public final class ConfiguredApplication implements Application { if ( ! qrConfig.rpc().enabled()) return null; // 1. Set up RPC server - supervisor = new Supervisor(new Transport("slobrok")); + supervisor = new Supervisor(new Transport("slobrok")).enableSmallBuffers(); Spec listenSpec = new Spec(qrConfig.rpc().port()); try { acceptor = supervisor.listen(listenSpec); diff --git a/jrt/src/com/yahoo/jrt/Supervisor.java b/jrt/src/com/yahoo/jrt/Supervisor.java index d4168e97743..ed94adcadd1 100644 --- a/jrt/src/com/yahoo/jrt/Supervisor.java +++ b/jrt/src/com/yahoo/jrt/Supervisor.java @@ -15,6 +15,8 @@ import java.util.concurrent.atomic.AtomicReference; **/ public class Supervisor { + private static final int SMALL_INPUT_BUFFER_SIZE = 20 * 1024; // Large enough too hold the typical application buffersize of 17k. + private static final int SMALL_OUTPUT_BUFFER_SIZE = 8 *1024; // Suitable small buffer usage with many connections and little traffic. private final Transport transport; private SessionHandler sessionHandler = null; private final Object methodMapLock = new Object(); @@ -34,6 +36,16 @@ public class Supervisor { } /** + * Will optimize buffers size for small memory footprint + * Use this when you have many connections with very little traffic. + **/ + public Supervisor enableSmallBuffers() { + setMaxInputBufferSize(SMALL_INPUT_BUFFER_SIZE); + setMaxOutputBufferSize(SMALL_OUTPUT_BUFFER_SIZE); + return this; + } + + /** * Set maximum input buffer size. This value will only affect * connections that use a common input buffer when decoding * incoming packets. Note that this value is not an absolute diff --git a/jrt/src/com/yahoo/jrt/slobrok/api/Mirror.java b/jrt/src/com/yahoo/jrt/slobrok/api/Mirror.java index 5a4a79995d8..6bceb7a1db0 100644 --- a/jrt/src/com/yahoo/jrt/slobrok/api/Mirror.java +++ b/jrt/src/com/yahoo/jrt/slobrok/api/Mirror.java @@ -57,6 +57,7 @@ public class Mirror implements IMirror { **/ public Mirror(Supervisor orb, SlobrokList slobroks, BackOffPolicy bop) { this.orb = orb; + orb.enableSmallBuffers(); this.slobroks = slobroks; this.backOff = bop; transportThread = orb.transport().selectThread(); diff --git a/jrt/src/com/yahoo/jrt/slobrok/server/Slobrok.java b/jrt/src/com/yahoo/jrt/slobrok/server/Slobrok.java index f19779732ba..1a0c94b9bd0 100644 --- a/jrt/src/com/yahoo/jrt/slobrok/server/Slobrok.java +++ b/jrt/src/com/yahoo/jrt/slobrok/server/Slobrok.java @@ -39,7 +39,7 @@ public class Slobrok { public Slobrok(int port) throws ListenFailedException { // NB: rpc must be single-threaded - orb = new Supervisor(new Transport("slobrok-" + port, 1)); + orb = new Supervisor(new Transport("slobrok-" + port, 1)).enableSmallBuffers(); registerMethods(); try { listener = orb.listen(new Spec(port)); diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/rpc/RpcConnector.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/rpc/RpcConnector.java index 9408c9b917a..75b099630c3 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/rpc/RpcConnector.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/rpc/RpcConnector.java @@ -27,7 +27,7 @@ public class RpcConnector extends AbstractComponent { private final Acceptor acceptor; public RpcConnector(RpcConnectorConfig config) { - supervisor = new Supervisor(new Transport("rpc-" + config.port())); + supervisor = new Supervisor(new Transport("rpc-" + config.port())).enableSmallBuffers(); Spec spec = new Spec(config.port()); try { acceptor = supervisor.listen(spec); diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/ConfigSentinelClient.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/ConfigSentinelClient.java index 1fd444332d6..10e75c53ed7 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/ConfigSentinelClient.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/ConfigSentinelClient.java @@ -24,10 +24,11 @@ import java.util.logging.Logger; public class ConfigSentinelClient extends AbstractComponent { private final static Logger log = Logger.getLogger(ConfigSentinelClient.class.getName()); - private final Supervisor supervisor = new Supervisor(new Transport("sentinel-client")); + private final Supervisor supervisor; @Inject public ConfigSentinelClient() { + supervisor = new Supervisor(new Transport("sentinel-client")).enableSmallBuffers(); } @Override |