diff options
author | Benoit Foucher <benoit@zeroc.com> | 2007-05-23 12:51:51 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2007-05-23 12:51:51 +0000 |
commit | c1323acecce7e15c58a0842da68f9cfc357355b2 (patch) | |
tree | e3ccf8b3fcf50997a65b385b03b37e07ba011752 /java/src/IceInternal/TcpTransceiver.java | |
parent | Added Ice.TCP.SndSize/Ice.TCP.RcvSize properties, fixed throughput issue on (diff) | |
download | ice-c1323acecce7e15c58a0842da68f9cfc357355b2.tar.bz2 ice-c1323acecce7e15c58a0842da68f9cfc357355b2.tar.xz ice-c1323acecce7e15c58a0842da68f9cfc357355b2.zip |
Added Ice.TCP.SndSize/Ice.TCP.RcvSize properties, fixed throughput
performance issue on Win32.
Diffstat (limited to 'java/src/IceInternal/TcpTransceiver.java')
-rw-r--r-- | java/src/IceInternal/TcpTransceiver.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/java/src/IceInternal/TcpTransceiver.java b/java/src/IceInternal/TcpTransceiver.java index e2af6f90a6b..8b5693fdb3f 100644 --- a/java/src/IceInternal/TcpTransceiver.java +++ b/java/src/IceInternal/TcpTransceiver.java @@ -149,6 +149,13 @@ final class TcpTransceiver implements Transceiver throws LocalExceptionWrapper { java.nio.ByteBuffer buf = stream.prepareWrite(); + int size = buf.limit(); + int packetSize = 0; + if(_maxPacketSize > 0 && size > _maxPacketSize) + { + packetSize = _maxPacketSize; + buf.limit(buf.position() + packetSize); + } while(buf.hasRemaining()) { @@ -210,6 +217,21 @@ final class TcpTransceiver implements Transceiver { _stats.bytesSent(type(), ret); } + + if(packetSize > 0) + { + assert(buf.position() == buf.limit()); + int position = buf.position(); + if(size - position > packetSize) + { + buf.limit(position + packetSize); + } + else + { + packetSize = 0; + buf.limit(size); + } + } } catch(java.io.InterruptedIOException ex) { @@ -351,6 +373,21 @@ final class TcpTransceiver implements Transceiver _logger = instance.initializationData().logger; _stats = instance.initializationData().stats; _desc = Network.fdToString(_fd); + + _maxPacketSize = 0; + if(System.getProperty("os.name").startsWith("Windows")) + { + // + // On Windows, limiting the buffer size is important to prevent + // poor throughput performances when transfering large amount of + // data. See Microsoft KB article KB823764. + // + _maxPacketSize = Network.getSendBufferSize(_fd) / 2; + if(_maxPacketSize < 512) + { + _maxPacketSize = 0; + } + } } protected synchronized void @@ -369,4 +406,5 @@ final class TcpTransceiver implements Transceiver private String _desc; private java.nio.channels.Selector _readSelector; private java.nio.channels.Selector _writeSelector; + private int _maxPacketSize; } |