You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Lars Hofhansl (JIRA)" <ji...@apache.org> on 2014/01/13 02:42:52 UTC

[jira] [Comment Edited] (HBASE-10320) Avoid ArrayList.iterator() in tight loops

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

Lars Hofhansl edited comment on HBASE-10320 at 1/13/14 1:42 AM:
----------------------------------------------------------------

Looks like the JDK is getting smart with multiple threads. In the case where l.size() is part of the loop condition I see more cores doing work.

I need to do some more tests.



was (Author: lhofhansl):
Looks like the JDK is getting smart with multiple threads. I need to do some more tests.


> 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.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)