dartist / redis_client

A high-performance async/non-blocking Redis client for Dart
BSD 2-Clause "Simplified" License
100 stars 29 forks source link

disable Nagle's algo. performance increase by factor #53

Closed ra1u closed 9 years ago

ra1u commented 9 years ago

By default, it is Nagle's algo enabled for socket. http://en.wikipedia.org/wiki/Nagle%27s_algorithm I haven measured exactly speedup seems to be like 10 times.

mythz commented 9 years ago

ok interesting, thx.

ra1u commented 9 years ago
import "package:redis_client/redis_client.dart";    
const int N = 10000; 

void test1(RedisClient client){
  void recursive_loop(RedisClient client,int n){
    if(n<0){
      print("done");
      return;
    }
    if(n%(N/100) == 0){
      print("$n");
    }
    client.set("test $n", "$n")
    .then((_) => client.get("test $n")
      .then((value){
        recursive_loop(client,n-1);
      }
     ));
  }
  recursive_loop(client,N);
}

main() {
  var connectionString = "localhost:6379";
  RedisClient.connect(connectionString)
  .then(test1);
}