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

Elliott Clark commented on HBASE-10320:
---------------------------------------

Just ran some micro benchmarks using caliper and I got the following results: 
https://microbenchmarks.appspot.com/runs/37ac8b21-da30-4694-a9fb-f58592b338f0

Not quite as dramatic as [~lhofhansl] is seeing but still suggests that 
replacing for(x:y) with array based will be worth it.

Code for benchmark: https://github.com/elliottneilclark/iter-bench
JVM: 
{code}
eclark@eclark-MBPr ~/Code/public/iter-bench (master)$ java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
{code}

> Avoid ArrayList.iterator() in tight loops
> -----------------------------------------
>
>                 Key: HBASE-10320
>                 URL: https://issues.apache.org/jira/browse/HBASE-10320
>             Project: HBase
>          Issue Type: Bug
>          Components: Performance
>            Reporter: Lars Hofhansl
>         Attachments: 10320-0.94-v2.txt, 10320-0.94-v3.txt, 10320-0.94.txt
>
>
> I noticed that in a profiler (sampler) run ScanQueryMatcher.setRow(...) 
> showed up at all.
> In turns out that the expensive part is iterating over the columns in 
> ExcplicitColumnTracker.reset(). I did some microbenchmarks and found that
> {code}
> private ArrayList<X> l;
> ...
> for (int i=0; i<l.size(); i++) {
>    X = l.get(i);
>    ...
> }
> {code}
> Is twice as fast as:
> {code}
> private ArrayList<X> l;
> ...
> for (X : l) {
>    ...
> }
> {code}
> The indexed version asymptotically approaches the iterator version, but even 
> at 1m entries it is still faster.
> In my tight loop scans this provides for a 5% performance improvement overall 
> when the ExcplicitColumnTracker is used.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to