You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@bval.apache.org by "Jarek Gawor (JIRA)" <ji...@apache.org> on 2012/09/27 03:15:07 UTC

[jira] [Created] (BVAL-113) Minor performance improvements

Jarek Gawor created BVAL-113:
--------------------------------

             Summary: Minor performance improvements
                 Key: BVAL-113
                 URL: https://issues.apache.org/jira/browse/BVAL-113
             Project: BVal
          Issue Type: Improvement
          Components: jsr303
    Affects Versions: 0.4, 0.5
            Reporter: Jarek Gawor


We found a couple of minor performance issues that came up during our profiling: 

1) AnnotationProcessor.java, FeaturesCapable.java, and MetaBean.java use ArrayUtils.add() to grow the array. The issue is that ArrayUtils.add() uses reflection to grown the array which 1) is slower then just instantiating the array, and 2) is completely unnecessary in these cases as the type of the array is always well known and doesn't change.

2) MetaBean.java stores MetaProperty objects in a sorted array and uses binary search to lookup and insert them. An implementation that stores these objects in a map would offer faster lookup and insert performance.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (BVAL-113) Minor performance improvements

Posted by "Jarek Gawor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BVAL-113?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jarek Gawor updated BVAL-113:
-----------------------------

    Attachment: PerfTest.java

I attached the test I used to generate the performance results for MetaBean.
                
> Minor performance improvements
> ------------------------------
>
>                 Key: BVAL-113
>                 URL: https://issues.apache.org/jira/browse/BVAL-113
>             Project: BVal
>          Issue Type: Improvement
>          Components: jsr303
>    Affects Versions: 0.4, 0.5
>            Reporter: Jarek Gawor
>         Attachments: BVAL-113.patch, PerfTest.java
>
>
> We found a couple of minor performance issues that came up during our profiling: 
> 1) AnnotationProcessor.java, FeaturesCapable.java, and MetaBean.java use ArrayUtils.add() to grow the array. The issue is that ArrayUtils.add() uses reflection to grown the array which 1) is slower then just instantiating the array, and 2) is completely unnecessary in these cases as the type of the array is always well known and doesn't change.
> 2) MetaBean.java stores MetaProperty objects in a sorted array and uses binary search to lookup and insert them. An implementation that stores these objects in a map would offer faster lookup and insert performance.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (BVAL-113) Minor performance improvements

Posted by "Matt Benson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BVAL-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13469495#comment-13469495 ] 

Matt Benson commented on BVAL-113:
----------------------------------

Hi Jarek, and thanks for providing these numbers.  I modified your test a bit further to store the items in a local list, shuffling it before add/retrieve to emulate the unpredictability of property registration/retrieval, at some risk to the impartiality of a given run.  My numbers are similar to yours, though I have runs showing 2s for 100 properties with both the original code and the code including all your suggested changes modulo the {{MetaBean}} changes, and 1s for 100 properties with the change to storing properties in a {{HashMap}}.  These gains are counterbalanced against the array creation that must take place when retrieving _all_ {{MetaProperty}}s; however my inclination is that they are compelling enough to include.  Thanks again for your interest.
                
> Minor performance improvements
> ------------------------------
>
>                 Key: BVAL-113
>                 URL: https://issues.apache.org/jira/browse/BVAL-113
>             Project: BVal
>          Issue Type: Improvement
>          Components: jsr303
>    Affects Versions: 0.4, 0.5
>            Reporter: Jarek Gawor
>         Attachments: BVAL-113.patch, PerfTest.java
>
>
> We found a couple of minor performance issues that came up during our profiling: 
> 1) AnnotationProcessor.java, FeaturesCapable.java, and MetaBean.java use ArrayUtils.add() to grow the array. The issue is that ArrayUtils.add() uses reflection to grown the array which 1) is slower then just instantiating the array, and 2) is completely unnecessary in these cases as the type of the array is always well known and doesn't change.
> 2) MetaBean.java stores MetaProperty objects in a sorted array and uses binary search to lookup and insert them. An implementation that stores these objects in a map would offer faster lookup and insert performance.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (BVAL-113) Minor performance improvements

Posted by "Jarek Gawor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BVAL-113?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jarek Gawor updated BVAL-113:
-----------------------------

    Attachment: BVAL-113.patch

I attached patch that addresses the performance issues described above.

                
> Minor performance improvements
> ------------------------------
>
>                 Key: BVAL-113
>                 URL: https://issues.apache.org/jira/browse/BVAL-113
>             Project: BVal
>          Issue Type: Improvement
>          Components: jsr303
>    Affects Versions: 0.4, 0.5
>            Reporter: Jarek Gawor
>         Attachments: BVAL-113.patch
>
>
> We found a couple of minor performance issues that came up during our profiling: 
> 1) AnnotationProcessor.java, FeaturesCapable.java, and MetaBean.java use ArrayUtils.add() to grow the array. The issue is that ArrayUtils.add() uses reflection to grown the array which 1) is slower then just instantiating the array, and 2) is completely unnecessary in these cases as the type of the array is always well known and doesn't change.
> 2) MetaBean.java stores MetaProperty objects in a sorted array and uses binary search to lookup and insert them. An implementation that stores these objects in a map would offer faster lookup and insert performance.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (BVAL-113) Minor performance improvements

Posted by "Matt Benson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BVAL-113?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Benson updated BVAL-113:
-----------------------------

    Fix Version/s: 1.0
    
> Minor performance improvements
> ------------------------------
>
>                 Key: BVAL-113
>                 URL: https://issues.apache.org/jira/browse/BVAL-113
>             Project: BVal
>          Issue Type: Improvement
>          Components: jsr303
>    Affects Versions: 0.4, 0.5
>            Reporter: Jarek Gawor
>             Fix For: 1.0, 0.6
>
>         Attachments: BVAL-113.patch, PerfTest.java
>
>
> We found a couple of minor performance issues that came up during our profiling: 
> 1) AnnotationProcessor.java, FeaturesCapable.java, and MetaBean.java use ArrayUtils.add() to grow the array. The issue is that ArrayUtils.add() uses reflection to grown the array which 1) is slower then just instantiating the array, and 2) is completely unnecessary in these cases as the type of the array is always well known and doesn't change.
> 2) MetaBean.java stores MetaProperty objects in a sorted array and uses binary search to lookup and insert them. An implementation that stores these objects in a map would offer faster lookup and insert performance.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (BVAL-113) Minor performance improvements

Posted by "Matt Benson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BVAL-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13469572#comment-13469572 ] 

Matt Benson commented on BVAL-113:
----------------------------------

Numbers still look good using {{TreeMap}} which will preserve the sortedness of the properties array returned in case any consumers rely on that.
                
> Minor performance improvements
> ------------------------------
>
>                 Key: BVAL-113
>                 URL: https://issues.apache.org/jira/browse/BVAL-113
>             Project: BVal
>          Issue Type: Improvement
>          Components: jsr303
>    Affects Versions: 0.4, 0.5
>            Reporter: Jarek Gawor
>         Attachments: BVAL-113.patch, PerfTest.java
>
>
> We found a couple of minor performance issues that came up during our profiling: 
> 1) AnnotationProcessor.java, FeaturesCapable.java, and MetaBean.java use ArrayUtils.add() to grow the array. The issue is that ArrayUtils.add() uses reflection to grown the array which 1) is slower then just instantiating the array, and 2) is completely unnecessary in these cases as the type of the array is always well known and doesn't change.
> 2) MetaBean.java stores MetaProperty objects in a sorted array and uses binary search to lookup and insert them. An implementation that stores these objects in a map would offer faster lookup and insert performance.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (BVAL-113) Minor performance improvements

Posted by "Matt Benson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BVAL-113?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Benson resolved BVAL-113.
------------------------------

       Resolution: Fixed
    Fix Version/s: 0.6

Committed revision 1394367.
                
> Minor performance improvements
> ------------------------------
>
>                 Key: BVAL-113
>                 URL: https://issues.apache.org/jira/browse/BVAL-113
>             Project: BVal
>          Issue Type: Improvement
>          Components: jsr303
>    Affects Versions: 0.4, 0.5
>            Reporter: Jarek Gawor
>             Fix For: 0.6
>
>         Attachments: BVAL-113.patch, PerfTest.java
>
>
> We found a couple of minor performance issues that came up during our profiling: 
> 1) AnnotationProcessor.java, FeaturesCapable.java, and MetaBean.java use ArrayUtils.add() to grow the array. The issue is that ArrayUtils.add() uses reflection to grown the array which 1) is slower then just instantiating the array, and 2) is completely unnecessary in these cases as the type of the array is always well known and doesn't change.
> 2) MetaBean.java stores MetaProperty objects in a sorted array and uses binary search to lookup and insert them. An implementation that stores these objects in a map would offer faster lookup and insert performance.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (BVAL-113) Minor performance improvements

Posted by "Matt Benson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BVAL-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464441#comment-13464441 ] 

Matt Benson commented on BVAL-113:
----------------------------------

Hi, thanks for your interest!  Would you have any performance metrics available to show the increases gained?

Thanks,
Matt
                
> Minor performance improvements
> ------------------------------
>
>                 Key: BVAL-113
>                 URL: https://issues.apache.org/jira/browse/BVAL-113
>             Project: BVal
>          Issue Type: Improvement
>          Components: jsr303
>    Affects Versions: 0.4, 0.5
>            Reporter: Jarek Gawor
>         Attachments: BVAL-113.patch
>
>
> We found a couple of minor performance issues that came up during our profiling: 
> 1) AnnotationProcessor.java, FeaturesCapable.java, and MetaBean.java use ArrayUtils.add() to grow the array. The issue is that ArrayUtils.add() uses reflection to grown the array which 1) is slower then just instantiating the array, and 2) is completely unnecessary in these cases as the type of the array is always well known and doesn't change.
> 2) MetaBean.java stores MetaProperty objects in a sorted array and uses binary search to lookup and insert them. An implementation that stores these objects in a map would offer faster lookup and insert performance.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (BVAL-113) Minor performance improvements

Posted by "Jarek Gawor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BVAL-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13467910#comment-13467910 ] 

Jarek Gawor commented on BVAL-113:
----------------------------------

Here's some results from my micro-benchmarks. This is just one set of results from a few runs on my machine using Oracle Java 6.

HashMap implementation (new):
time (100): 4
time (1000): 23
time (10000): 99
time (100000): 151

Array implementation (current):
time (100): 4
time (1000): 41
time (10000): 340
time (100000): 17653

The HashMap implementation is much better at larger number of properties but probably in most cases there will be less then 100 properties in a MetaBean object. And if so it doesn't seem as important to apply this patch.

                
> Minor performance improvements
> ------------------------------
>
>                 Key: BVAL-113
>                 URL: https://issues.apache.org/jira/browse/BVAL-113
>             Project: BVal
>          Issue Type: Improvement
>          Components: jsr303
>    Affects Versions: 0.4, 0.5
>            Reporter: Jarek Gawor
>         Attachments: BVAL-113.patch
>
>
> We found a couple of minor performance issues that came up during our profiling: 
> 1) AnnotationProcessor.java, FeaturesCapable.java, and MetaBean.java use ArrayUtils.add() to grow the array. The issue is that ArrayUtils.add() uses reflection to grown the array which 1) is slower then just instantiating the array, and 2) is completely unnecessary in these cases as the type of the array is always well known and doesn't change.
> 2) MetaBean.java stores MetaProperty objects in a sorted array and uses binary search to lookup and insert them. An implementation that stores these objects in a map would offer faster lookup and insert performance.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (BVAL-113) Minor performance improvements

Posted by "Matt Benson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BVAL-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13469495#comment-13469495 ] 

Matt Benson edited comment on BVAL-113 at 10/5/12 3:44 AM:
-----------------------------------------------------------

Hi Jarek, and thanks for providing these numbers.  I modified your test a bit further to store the items in a local list, shuffling it before add/retrieve to emulate the unpredictability of property registration/retrieval, at some risk to the impartiality of a given run.  My numbers are similar to yours, though I have runs showing 2s for 100 properties with both the original code and the code including all your suggested changes modulo the {{MetaBean}} changes, and 1s for 100 properties with the change to storing properties in a {{HashMap}}.  These gains are counterbalanced against the array creation that must take place when retrieving _all_ {{MetaProperty}} members; however my inclination is that they are compelling enough to include.  Thanks again for your interest.
                
      was (Author: mbenson):
    Hi Jarek, and thanks for providing these numbers.  I modified your test a bit further to store the items in a local list, shuffling it before add/retrieve to emulate the unpredictability of property registration/retrieval, at some risk to the impartiality of a given run.  My numbers are similar to yours, though I have runs showing 2s for 100 properties with both the original code and the code including all your suggested changes modulo the {{MetaBean}} changes, and 1s for 100 properties with the change to storing properties in a {{HashMap}}.  These gains are counterbalanced against the array creation that must take place when retrieving _all_ {{MetaProperty}}s; however my inclination is that they are compelling enough to include.  Thanks again for your interest.
                  
> Minor performance improvements
> ------------------------------
>
>                 Key: BVAL-113
>                 URL: https://issues.apache.org/jira/browse/BVAL-113
>             Project: BVal
>          Issue Type: Improvement
>          Components: jsr303
>    Affects Versions: 0.4, 0.5
>            Reporter: Jarek Gawor
>         Attachments: BVAL-113.patch, PerfTest.java
>
>
> We found a couple of minor performance issues that came up during our profiling: 
> 1) AnnotationProcessor.java, FeaturesCapable.java, and MetaBean.java use ArrayUtils.add() to grow the array. The issue is that ArrayUtils.add() uses reflection to grown the array which 1) is slower then just instantiating the array, and 2) is completely unnecessary in these cases as the type of the array is always well known and doesn't change.
> 2) MetaBean.java stores MetaProperty objects in a sorted array and uses binary search to lookup and insert them. An implementation that stores these objects in a map would offer faster lookup and insert performance.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira