Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Bulk Array Element Allocation, is it faster?

Reply
Thread Tools

Bulk Array Element Allocation, is it faster?

 
 
Jan Burse
Guest
Posts: n/a
 
      09-25-2011
Jan Burse schrieb:
> So what is going on in the 64bit?


Problem resolved! Thanks all for your attention and
good advise. Especially persisting in look at the
application, there was a bottleneck somewhere else.
Dunno why it wasn't seen for 32-bit, but anyway,
everything is fine now. Will revert to the lazy
version since it uses less memory...

Best Regards
 
Reply With Quote
 
 
 
 
Andreas Leitgeb
Guest
Posts: n/a
 
      09-26-2011
Jan Burse <(E-Mail Removed)> wrote:
> Jan Burse schrieb:
>> So what is going on in the 64bit?

> Problem resolved! Thanks all for your attention and
> good advise. Especially persisting in look at the
> application, there was a bottleneck somewhere else.


If it can be demonstrated within the context of:
bulk instanciation in a loop
versus
on-demand instanciation ("lazy")
then I'd be curious about where/what that extra bottleneck
was.

> Dunno why it wasn't seen for 32-bit, ...

 
Reply With Quote
 
 
 
 
Jan Burse
Guest
Posts: n/a
 
      09-26-2011
Andreas Leitgeb schrieb:
> Jan Burse<(E-Mail Removed)> wrote:
>> Jan Burse schrieb:
>>> So what is going on in the 64bit?

>> Problem resolved! Thanks all for your attention and
>> good advise. Especially persisting in look at the
>> application, there was a bottleneck somewhere else.

>
> If it can be demonstrated within the context of:
> bulk instanciation in a loop
> versus
> on-demand instanciation ("lazy")
> then I'd be curious about where/what that extra bottleneck
> was.
>
>> Dunno why it wasn't seen for 32-bit, ...


Lets assume the following simplified lazy code:

bla = new Bla[n];
..
if (bla[i]==null) /* the null test */
bla[i]=new Bla(); /* the new call */
..

I thought that in the lazy version, bla[i] was
maximally n times tested for null. It was
based on the figures I obtained, namely
counting the new calls in bulk and in lazy:

Bulk: 84'393'262
Lazy: 81'662'843
http://www.facebook.com/photo.php?fbid=199117193490169

But the number of new calls is not the
same as the number of null tests, since
a new call is only performed when the null
test succeeds.

So it turned out that there were much more
null tests than new calls. In certain sub
test cases the number can arbirarily go up, so
instead of n tests one might have m*n tests
where m depends on the sub test case, and
is not related to n.

Since my null test is in practice a little
bit more complex in my application and since
m is much above 1 in many of my sub test
cases, the overhead became recognizable.

Meanwhile I could reduce the complexity and
subsequently the frequency of the null test
in my application and the overhead for lazy
has dimished.

There is a little guard which is called like
m times. And then the null test is maximally
n times done. Since the guard is cheap and
since it guards a couple of null tests, the
overhead is now small.

Bye
 
Reply With Quote
 
Jan Burse
Guest
Posts: n/a
 
      09-26-2011
Jan Burse schrieb:
> There is a little guard which is called like
> m times. And then the null test is maximally
> n times done. Since the guard is cheap and
> since it guards a couple of null tests, the
> overhead is now small.


This could be transformed to other problems.
Like for example an uninitialized matrice.
Just put the guard on the rows of a matrice,
and intialize rows in a bulk instead of the
elements of the matrice. Clearly this gives
a speed-up.

Why is still null test on elements needed?
Well the guard is reset from time to time.
At least this happens in my application.
Because otherwise one could object, the
guard is enough, why should there be
additional null tests on elements?

Bye



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
find if an array has any element present in another array Charanya Nagarajan Ruby 6 04-30-2009 11:14 AM
Once again pointer to first element vs pointer to array cast topointer to element Szabolcs Borsanyi C Programming 6 05-23-2008 11:06 AM
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
If given 1 element in an array of textboxes... find which element number it is \A_Michigan_User\ Javascript 4 11-16-2007 12:58 PM
How to delete array element and add to previous element Al Cholic Ruby 18 07-28-2007 04:56 PM



Advertisments