rmannibucau commented on issue #577: cxf-rt-rs-client: use ArrayList in 
ClientProxyImpl
URL: https://github.com/apache/cxf/pull/577#issuecomment-528265685
 
 
   Ok, ran a comparison on a recent JVM - didn't recheck that since years, I 
get something close to your test:
   
       size     array   linked  diff
       0        40      32      -8
       1        136     112     -24
       2        192     192     0
       3        248     272     24
       4        304     352     48
       5        360     432     72
       6        416     512     96
       7        472     592     120
       8        528     672     144
       9        584     752     168
       10       640     832     192
       11       720     912     192
       12       776     992     216
       13       832     1072    240
       14       888     1152    264
       15       944     1232    288
       16       1024    1312    288
       17       1080    1392    312
       18       1136    1472    336
       19       1192    1552    360
       20       1248    1632    384
       21       1304    1712    408
       22       1360    1792    432
       23       1464    1872    408
       24       1520    1952    432
       25       1576    2032    456
       26       1632    2112    480
       27       1688    2192    504
       28       1744    2272    528
       29       1800    2352    552
       30       1856    2432    576
       31       1912    2512    600
       32       1968    2592    624
   
   So long story short, for 0 or 1 parameter, linked list is better, for 2, 
there is no real different (except linked list would be a very little bit 
slower and then arraylist is better and moreover more stable in terms of 
allocations so guess this is actually a very good change, sorry for the false 
warning.
   
   Side note: here is what I used to generate ^^ if anyone wants to give a try 
on openj9 or another VM version (used zulu 202):
   
       import static 
jdk.nashorn.internal.ir.debug.ObjectSizeCalculator.getObjectSize;
       
       import java.lang.reflect.Field;
       import java.util.ArrayList;
       import java.util.LinkedList;
       import java.util.List;
       
       public class Tmp {
           public static void main(final String[] args) {
               System.setProperty("java.vm.name", "Java HotSpot(TM) tmp"); // 
to reuse nashorn object size evaluator
       
               final List<Object> linked = new LinkedList<>();
               final List<Object> array = new ArrayList<>();
               System.out.println("size;array;linked");
               csv(0, array, linked);
               for (int i = 0; i < 32; i++) {
                   final String value = "test" + i;
                   linked.add(value);
                   array.add(value);
                   csv(i + 1, array, linked);
               }
               if (!array.equals(linked)) {
                   throw new IllegalStateException("Something went wrong: \n" + 
array + "\n" + linked);
               }
           }
       
           private static void csv(final int size, final List<?> array, final 
List<?> linked) {
               System.out.print(size);
               System.out.print(';');
               System.out.print(getObjectSize(array));
               System.out.print(';');
               System.out.println(getObjectSize(linked));
           }
       }
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to