Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: more than 10 seconds to allocate an array!

Reply
Thread Tools

Re: more than 10 seconds to allocate an array!

 
 
Andy Flowers
Guest
Posts: n/a
 
      08-28-2003
Just for sport, how long does it take to allocate an array this size from a
C program ?

"Ahmed Moustafa" <> wrote in message
news:...
> S.A. Samokhodkin wrote:
> > Ahmed Moustafa writes:
> >
> >> On a SPARC E420, SunOS 5.8, JRE 1.4.1_02 and 1G RAM, it takes more
> >> than 10 seconds to allocate an array as
> >>
> >> <code>
> >> float[][] array = new float[10000][10000];
> >> </code>
> >>
> >> Is not that *very* slow?
> >>

> >
> > Supposedly because of the GC.
> > Try -Xmx > 10^8*4 + O(10^.

>
> I am already using -Xms1024m -Xmx1024m. And it is the only code in the
> test program, so why could be the GC?
>



 
Reply With Quote
 
 
 
 
Thomas G. Marshall
Guest
Posts: n/a
 
      08-28-2003

> "Ahmed Moustafa" <> wrote in message
> news:...
>> S.A. Samokhodkin wrote:
>>> Ahmed Moustafa writes:
>>>
>>>> On a SPARC E420, SunOS 5.8, JRE 1.4.1_02 and 1G RAM, it takes more
>>>> than 10 seconds to allocate an array as
>>>>
>>>> <code>
>>>> float[][] array = new float[10000][10000];
>>>> </code>
>>>>
>>>> Is not that *very* slow?
>>>>
>>>
>>> Supposedly because of the GC.
>>> Try -Xmx > 10^8*4 + O(10^.

>>
>> I am already using -Xms1024m -Xmx1024m. And it is the only code in
>> the test program, so why could be the GC?


Andy Flowers <> horrified us with:

> Just for sport, how long does it take to allocate an array this size
> from a C program ?


Excellent question. Perfect fault isolation.

Just remember on unix that you have /process/ size to worry about. You
know, sbrk() and all....

PS. If you wanna top post, that's fine with me, just don't do it after
others have already bottom posted. You're making a hell of a mess...




 
Reply With Quote
 
 
 
 
Ahmed Moustafa
Guest
Posts: n/a
 
      08-28-2003
Andy Flowers wrote:
> Just for sport, how long does it take to allocate an array this size from a
> C program ?


It took nothing! Not only the array allocation but also looping over the
array and printing the contents!

 
Reply With Quote
 
Ahmed Moustafa
Guest
Posts: n/a
 
      08-29-2003
>> Just for sport, how long does it take to allocate an array this size
>> from a
>> C program ?

>
>
> It took nothing! Not only the array allocation but also looping over the
> array and printing the contents!


BTW, below is the C test program
<code>
#include <stdio.h>
int main(void) {
float f[10000];
for (int i = 0; i < 10000; i++) {
f[i] = 0;
printf ("%d\t%f", i, f[i]);
}
}
</code>

 
Reply With Quote
 
Marco Schmidt
Guest
Posts: n/a
 
      08-29-2003
Ahmed Moustafa:

>> It took nothing! Not only the array allocation but also looping over the
>> array and printing the contents!


>#include <stdio.h>
>int main(void) {
> float f[10000];
> for (int i = 0; i < 10000; i++) {
> f[i] = 0;
> printf ("%d\t%f", i, f[i]);
> }
>}


But that's a 1-D array with 10000 elements, not a 2-D array with
10000^2 elements, and the data is not dynamically allocated either, as
far as I can see.

Regards,
Marco
--
Please reply in the newsgroup, not by email!
Java programming tips: http://jiu.sourceforge.net/javatips.html
Other Java pages: http://www.geocities.com/marcoschmidt.geo/java.html
 
Reply With Quote
 
Ahmed Moustafa
Guest
Posts: n/a
 
      08-29-2003
Marco Schmidt wrote:
> Ahmed Moustafa:
>
>
>>>It took nothing! Not only the array allocation but also looping over the
>>>array and printing the contents!

>
>
>>#include <stdio.h>
>>int main(void) {
>> float f[10000];
>> for (int i = 0; i < 10000; i++) {
>> f[i] = 0;
>> printf ("%d\t%f", i, f[i]);
>> }
>>}

>
>
> But that's a 1-D array with 10000 elements, not a 2-D array with
> 10000^2 elements, and the data is not dynamically allocated either, as
> far as I can see.


Yes, I realized the missing dimension just I after the post. I have
tested it again with 2 dimension, and the result is the same, very fast.

 
Reply With Quote
 
Thomas G. Marshall
Guest
Posts: n/a
 
      08-29-2003
Ahmed Moustafa <> horrified us with:

> Marco Schmidt wrote:
>> Ahmed Moustafa:
>>
>>
>>>> It took nothing! Not only the array allocation but also looping
>>>> over the array and printing the contents!

>>
>>
>>> #include <stdio.h>
>>> int main(void) {
>>> float f[10000];
>>> for (int i = 0; i < 10000; i++) {
>>> f[i] = 0;
>>> printf ("%d\t%f", i, f[i]);
>>> }
>>> }

>>
>>
>> But that's a 1-D array with 10000 elements, not a 2-D array with
>> 10000^2 elements, and the data is not dynamically allocated either,
>> as far as I can see.

>
> Yes, I realized the missing dimension just I after the post. I have
> tested it again with 2 dimension, and the result is the same, very
> fast.


Still not a fair fight.

In the java case the 2-d array is 10k element array of 10k element arrays
and each of those arrays is a separate object instantiation.



 
Reply With Quote
 
Ahmed Moustafa
Guest
Posts: n/a
 
      08-29-2003
Thomas G. Marshall wrote:
> Ahmed Moustafa <> horrified us with:
>
>
>>Marco Schmidt wrote:
>>
>>>Ahmed Moustafa:
>>>
>>>
>>>
>>>>>It took nothing! Not only the array allocation but also looping
>>>>>over the array and printing the contents!
>>>
>>>
>>>>#include <stdio.h>
>>>>int main(void) {
>>>> float f[10000];
>>>> for (int i = 0; i < 10000; i++) {
>>>> f[i] = 0;
>>>> printf ("%d\t%f", i, f[i]);
>>>> }
>>>>}
>>>
>>>
>>>But that's a 1-D array with 10000 elements, not a 2-D array with
>>>10000^2 elements, and the data is not dynamically allocated either,
>>>as far as I can see.

>>
>>Yes, I realized the missing dimension just I after the post. I have
>>tested it again with 2 dimension, and the result is the same, very
>>fast.

>
>
> Still not a fair fight.


It is not a fight. I just need to improve the speed my Java code. Is
there a way?

> In the java case the 2-d array is 10k element array of 10k element arrays
> and each of those arrays is a separate object instantiation.


 
Reply With Quote
 
Ahmed Moustafa
Guest
Posts: n/a
 
      08-29-2003
>>>>>>>It took nothing! Not only the array allocation but also looping
>>>>>>>over the array and printing the contents!
>>>>>
>>>>>
>>>>>>#include <stdio.h>
>>>>>>int main(void) {
>>>>>>float f[10000];
>>>>>>for (int i = 0; i < 10000; i++) {
>>>>>> f[i] = 0;
>>>>>> printf ("%d\t%f", i, f[i]);
>>>>>>}
>>>>>>}
>>>>>
>>>>>
>>>>>But that's a 1-D array with 10000 elements, not a 2-D array with
>>>>>10000^2 elements, and the data is not dynamically allocated either,
>>>>>as far as I can see.
>>>>
>>>>Yes, I realized the missing dimension just I after the post. I have
>>>>tested it again with 2 dimension, and the result is the same, very
>>>>fast.
>>>
>>>
>>>Still not a fair fight.

>>
>>It is not a fight. I just need to improve the speed my Java code. Is
>>there a way?
>>
>>
>>>In the java case the 2-d array is 10k element array of 10k element

>
> arrays
>
>>>and each of those arrays is a separate object instantiation.

>>

>
> Why do you need to allocate a 10000x10000 array of doubles ? What is the
> problem you are attempting to solve ?


I am trying to align two DNA sequences, each is 10k characters, using
Smith-Waterman algorithm.

 
Reply With Quote
 
Thomas G. Marshall
Guest
Posts: n/a
 
      08-29-2003
Ahmed Moustafa <> horrified us with:

>>>>>>>> It took nothing! Not only the array allocation but also looping
>>>>>>>> over the array and printing the contents!
>>>>>>
>>>>>>
>>>>>>> #include <stdio.h>
>>>>>>> int main(void) {
>>>>>>> float f[10000];
>>>>>>> for (int i = 0; i < 10000; i++) {
>>>>>>> f[i] = 0;
>>>>>>> printf ("%d\t%f", i, f[i]);
>>>>>>> }
>>>>>>> }
>>>>>>
>>>>>>
>>>>>> But that's a 1-D array with 10000 elements, not a 2-D array with
>>>>>> 10000^2 elements, and the data is not dynamically allocated
>>>>>> either, as far as I can see.
>>>>>
>>>>> Yes, I realized the missing dimension just I after the post. I
>>>>> have tested it again with 2 dimension, and the result is the
>>>>> same, very fast.
>>>>
>>>>
>>>> Still not a fair fight.
>>>
>>> It is not a fight. I just need to improve the speed my Java code. Is
>>> there a way?
>>>
>>>
>>>> In the java case the 2-d array is 10k element array of 10k element

>>
>> arrays
>>
>>>> and each of those arrays is a separate object instantiation.
>>>

>>
>> Why do you need to allocate a 10000x10000 array of doubles ? What is
>> the problem you are attempting to solve ?

>
> I am trying to align two DNA sequences, each is 10k characters, using
> Smith-Waterman algorithm.


Oh wow. I actually worked on a java program to do DNA slicing and MAN was
that an unweildy amount of data! We discovered TONS of bugs relating to the
innards of python and sql+. The java code (1.0 !) surprisingly had no
troubles at all.



 
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
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM
Why does new allocate more memory than there is?? Alan Gifford C++ 4 10-27-2003 10:01 AM
Re: more than 10 seconds to allocate an array! Mark Thornton Java 1 09-01-2003 08:19 AM
Re: more than 10 seconds to allocate an array! Jon Skeet Java 6 08-30-2003 07:19 PM
Re: more than 10 seconds to allocate an array! Thomas G. Marshall Java 2 08-28-2003 07:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57