Bug 53637 - performance problem in VectorSet.allAll()
Summary: performance problem in VectorSet.allAll()
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.9.1
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: 1.9.4
Assignee: Ant Notifications List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2012-08-02 00:29 UTC by Adrian Nistor
Modified: 2014-01-02 15:29 UTC (History)
1 user (show)



Attachments
patch (1.28 KB, patch)
2012-08-02 00:29 UTC, Adrian Nistor
Details | Diff
test (660 bytes, text/x-java)
2012-08-02 00:29 UTC, Adrian Nistor
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Nistor 2012-08-02 00:29:18 UTC
Created attachment 29149 [details]
patch

There is a performance problem in VectorSet.allAll().  It appears in
version 1.8.4 and also in revision 1367821.  I attached a test that
exposes this problem and a patch that fixes it.  On my machine, the
patch provides a 20X speedup for this test.

To run the test, just do:

$ java Test

The output for the un-patched version is:
Time is 439

The output for the patched version is:
Time is 22

The current implementation of "VectorSet.addAll(int index, Collection
c)" adds the elements of "c" one by one at "index" in the
"elementData" array.  These add operations are slow, because each of
them requires shifting to the right all the elements after "index".

The attached patch adds all the elements at once, and thus performs a
single shift.

The java.util.ArrayList "addAll(int index, Collection<? extends E> c)"
implementation also performs a single shift (like the patch), and does
not insert the elements one by one.
Comment 1 Adrian Nistor 2012-08-02 00:29:49 UTC
Created attachment 29150 [details]
test
Comment 2 Jesse Glick 2013-03-07 14:13:52 UTC
Did not make it into 1.9.0 but should be considered for 1.9.1.
Comment 3 Stefan Bodewig 2014-01-02 15:29:35 UTC
svn revision 1554830