10 Replies Latest reply on Oct 4, 2011 11:14 AM by galder.zamarreno

    cache reading performance

    yelin666

      I did some performance testing on Infinispan earlier last year, and the data for both reading and updating are satisfactory. Especially, the reading is real fast. However, recently the reading performance data we measured in our application is not good. I tried to create a very simple test with a local cache, and the reading is slow. Basically, for my following simple code, the update took less than 300 millisenconds, while the reading took around 12 seconds. Could you please suggest what I made wrong here?

       

      import java.util.ArrayList;

      import java.util.HashMap;

      import java.util.List;

      import java.util.Map;

      import org.infinispan.Cache;

      import org.infinispan.manager.DefaultCacheManager;

       

      public class ReadingTest {

          public final static int SIZE = 50000;

         

          public ReadingTest() {

          }

       

          public static void main(String[] args) {

              ReadingTest test = new ReadingTest();

              test.run();

          }

         

          public void run() {

              DefaultCacheManager cacheManager = new DefaultCacheManager();

              Cache cache = cacheManager.getCache();

              System.out.println("cache mode " + cache.getConfiguration().getCacheModeString());

             

              List<String> list = new ArrayList<String>(SIZE);

              for (int i=0; i<SIZE; i++) {

                  list.add(String.valueOf(i));

              }

             

              Map<String, String> map = new HashMap<String, String>(SIZE);

              for (String s : list) {

                  map.put(s, s);

              }

             

              long timeBefore = System.currentTimeMillis();

              cache.putAll(map);

              long time = System.currentTimeMillis() - timeBefore;

              System.out.println("Updated " + SIZE + " values in " + time + " milliseconds");

        

              List retList = new ArrayList(SIZE);

              timeBefore = System.currentTimeMillis();

              for (String s : list) {

                  retList.add(cache.get(s));

              }

              time = System.currentTimeMillis() - timeBefore;

              System.out.println("Read " + SIZE + " values in " + time + " milliseconds");

          }

             

      }

        • 1. Re: cache reading performance
          manik

          Hmm, have you tried taking profiler snapshots?

          • 2. Re: cache reading performance
            yelin666

            As the test is real simple, could you please run it on your side really quick, and let me know what result you get? I'd appreciate a quick response on this.

            • 3. Re: cache reading performance
              yelin666

              Attached are couple snapshots I took on profiling the CPU & memory. Do they contain the information you are looking for? Please let me know what you need.

               

              In general, for the above read, what's the reasonable time you would expect it to take? I'd appreciate your feedbacks.

              • 4. Re: cache reading performance
                dkittler

                Lin, perhaps I missed this somewhere but what version of Infinispan are you running this test against?

                • 5. Re: cache reading performance
                  yelin666

                  Derrick, I actually tried different versions, including 4.1.0.FINAL, 4.2.1.FINAL, and 5.0.1.FINAL. The reading performance data for different versions are pretty much the same. I am wondering if there are obvious problems in my testing code? Could someone try running the above code to get the performance data, and suggest what may be wrong in the code?

                  • 6. Re: cache reading performance
                    manik

                    Hi Lin - thanks for creating this, I've spotted the (trivial) problem.  I have a fix in place, and have just published 5.1.0-SNAPSHOT - could you give it a spin and see how it works for you?  Using your test, I used to see:

                     

                     

                    26-Sep-2011 06:48:35 org.infinispan.factories.AbstractComponentRegistry internalStart

                    INFO: ISPN000128: Infinispan version: Infinispan 'Pagoa' 5.0.1.FINAL

                    26-Sep-2011 06:48:35 org.infinispan.factories.AbstractComponentRegistry internalStart

                    INFO: ISPN000128: Infinispan version: Infinispan 'Pagoa' 5.0.1.FINAL

                    cache mode LOCAL

                    Updated 50000 values in 322 milliseconds

                    Read 50000 values in 3433 milliseconds

                     

                    and now with my patch from ISPN-1417:

                     

                    26-Sep-2011 06:49:33 org.infinispan.factories.GlobalComponentRegistry start

                    INFO: ISPN000128: Infinispan version: Infinispan 'Brahma' 5.1.0-SNAPSHOT

                    26-Sep-2011 06:49:33 org.infinispan.factories.GlobalComponentRegistry start

                    INFO: ISPN000128: Infinispan version: Infinispan 'Brahma' 5.1.0-SNAPSHOT

                    cache mode LOCAL

                    Updated 50000 values in 384 milliseconds

                    Read 50000 values in 152 milliseconds

                    • 7. Re: cache reading performance
                      yelin666

                      Thanks, Manik. It did make a huge improvement.

                       

                      I am wondering what trivial problem you have fixed? And how soon a formal release with this fix will be available?

                      • 8. Re: cache reading performance
                        manik

                        See this commit for details - https://github.com/maniksurtani/infinispan/commit/bfcb935656a1b18ae57c11b0f3d8b88bf20426f0

                         

                        This will be in 5.1.0.BETA1 which I hope to release over the weekend/early next week.

                        • 9. Re: cache reading performance
                          yelin666

                          Thanks!

                          • 10. Re: cache reading performance
                            galder.zamarreno

                            Btw, BETA1 is out now