alphazero / jredis

Java Client and Connectors for Redis
http://code.google.com/p/jredis/
Apache License 2.0
315 stars 136 forks source link

org.jredis.ri.alphazero.support.Convert is way, way, way to slow. #29

Closed antis0c closed 13 years ago

antis0c commented 13 years ago

Awesome I hit save by mistake.. one sec real report incoming =)

antis0c commented 13 years ago

I'm developing an Android application that utilizes JRedis, and noticed that connecting to a Redis server can take almost a minute depending on the speed of the device.

            ConnectionSpec spec = DefaultConnectionSpec.newSpec("xxxx", 6379, 3, new String("xxxx").getBytes());
            JRedis client = new JRedisClient(spec);

So I did a trace on these calls and found that the repeated iterations in Convert (both in the static initializer) and resulting methods were each taking over 30 seconds (when profiled).

static {
    for(int i=0; i<INT_P_65535; i++) Integer.toString(i).getBytes();
}

Is particularly bad..

antis0c commented 13 years ago

I'm checking the code out now, I understand why you're doing what you're doing - but it comes at an unacceptable performance hit (at least on slower/embedded devices). Unfortunately, JRedis is the only maintained Java Redis Client API currently =)

antis0c commented 13 years ago

Here's a link to a screenshot of the Android trace:

http://i.imgur.com/4esy9.png

alphazero commented 13 years ago

Great. I just got a android phone and was planning on running JRedis on it.

And yes, of course, grabbing that chunk of memory on classload is prohibitive for a mobile device.

But the RI is not intended for mobile devices. Its a server connector and is optimized for speed at cost of space and startup cost. Convert does in fact speed things up.

If you want to build out a RIM (RI Mobile) implementation for JRedis APIlet me know what you need in terms of support. Its quite modular so you should have good reuse if you base RIM on RI.

/R