Elffuss BraidHub

kikocis/java-driver public

Don't delay flushing when coalescing messages.
Changeseta3de8ec39d035051cceb59c4c1d839549ecc4d1beec746dcf94af21ffe5bcacc
Authorolim7t <omichallat+github@gmail.com> · 2015-06-27 00:11 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2015-06-27 00:11 +02:00
Parentse6301299a3ef

Browse the files at this changeset

1 file changed

modified driver-core/src/main/java/com/datastax/driver/core/Connection.java +4 −13
@@ -832,8 +832,6 @@
832832 final Queue<FlushItem> queued = new ConcurrentLinkedQueue<FlushItem>();
833833 final AtomicBoolean running = new AtomicBoolean(false);
834834 final HashSet<Channel> channels = new HashSet<Channel>();
835- final List<FlushItem> flushed = Lists.newArrayListWithExpectedSize(50);
836- int runsSinceFlush = 0;
837835 int runsWithNoWork = 0;
838836
839837 private Flusher(EventLoop eventLoop) {
@@ -856,20 +854,13 @@
856854 while (null != (flush = queued.poll())) {
857855 channels.add(flush.channel);
858856 flush.channel.write(flush.request).addListener(flush.listener);
859- flushed.add(flush);
860857 doneWork = true;
861858 }
862859
863- runsSinceFlush++;
864-
865- if (!doneWork || runsSinceFlush > 2 || flushed.size() > 50) {
866- for (Channel channel : channels)
867- channel.flush();
868-
869- channels.clear();
870- flushed.clear();
871- runsSinceFlush = 0;
872- }
860+ // Always flush what we have (don't artificially delay to try to coalesce more messages)
861+ for (Channel channel : channels)
862+ channel.flush();
863+ channels.clear();
873864
874865 if (doneWork) {
875866 runsWithNoWork = 0;