[ 
https://issues.apache.org/jira/browse/CALCITE-3878?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17068401#comment-17068401
 ] 

neoremind commented on CALCITE-3878:
------------------------------------

[~vladimirsitnikov] I update the code to return list, the result looks pretty 
much the same.
{code:java}
Benchmark                                                                  
(size)  Mode  Cnt     Score      Error   Units
ArrayListTest.testWithInitialCapacity                                         
256  avgt    4  1918.284 ± 1384.469   ns/op
ArrayListTest.testWithInitialCapacity:·gc.alloc.rate                          
256  avgt    4   492.327 ±  330.941  MB/sec
ArrayListTest.testWithInitialCapacity:·gc.alloc.rate.norm                     
256  avgt    4  1064.000 ±    0.001    B/op
ArrayListTest.testWithInitialCapacity:·gc.churn.PS_Eden_Space                 
256  avgt    4   492.318 ±  336.778  MB/sec
ArrayListTest.testWithInitialCapacity:·gc.churn.PS_Eden_Space.norm            
256  avgt    4  1063.841 ±   37.935    B/op
ArrayListTest.testWithInitialCapacity:·gc.churn.PS_Survivor_Space             
256  avgt    4     0.131 ±    0.354  MB/sec
ArrayListTest.testWithInitialCapacity:·gc.churn.PS_Survivor_Space.norm        
256  avgt    4     0.280 ±    0.630    B/op
ArrayListTest.testWithInitialCapacity:·gc.count                               
256  avgt    4   339.000             counts
ArrayListTest.testWithInitialCapacity:·gc.time                                
256  avgt    4   183.000                 ms
ArrayListTest.testWithoutInitialCapacity                                      
256  avgt    4  2354.479 ±  572.751   ns/op
ArrayListTest.testWithoutInitialCapacity:·gc.alloc.rate                       
256  avgt    4  1699.781 ±  415.378  MB/sec
ArrayListTest.testWithoutInitialCapacity:·gc.alloc.rate.norm                  
256  avgt    4  4544.000 ±    0.001    B/op
ArrayListTest.testWithoutInitialCapacity:·gc.churn.PS_Eden_Space              
256  avgt    4  1706.059 ±  392.494  MB/sec
ArrayListTest.testWithoutInitialCapacity:·gc.churn.PS_Eden_Space.norm         
256  avgt    4  4561.142 ±  197.365    B/op
ArrayListTest.testWithoutInitialCapacity:·gc.churn.PS_Survivor_Space          
256  avgt    4     0.113 ±    0.054  MB/sec
ArrayListTest.testWithoutInitialCapacity:·gc.churn.PS_Survivor_Space.norm     
256  avgt    4     0.302 ±    0.100    B/op
ArrayListTest.testWithoutInitialCapacity:·gc.count                            
256  avgt    4   378.000             counts
ArrayListTest.testWithoutInitialCapacity:·gc.time                             
256  avgt    4   214.000                 ms
{code}

> Make ArrayList creation with initial capacity when size is fixed
> ----------------------------------------------------------------
>
>                 Key: CALCITE-3878
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3878
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.22.0
>            Reporter: neoremind
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> I find many places in Calcite where _new ArrayList<>()_ is used, if the list 
> is expected to be immutable or not resizing, it is always a good manner to 
> create with initial capacity, better for memory usage and performance.
> I search all occurrences, focus on the core module, to make it safe, I only 
> update local variables with fixed size and not working in recursive method. 
> If the local variable reference goes out of scope, if resizing is needed, 
> things will work normally as well, so no side effect, but for the "escaping" 
> case, I am very conservative and do not change them.
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to