image
image

Go Back   macosx.com > Content & Information > Apple News, Rumors & Discussion

Reply
 
LinkBack Thread Tools
  #1  
Old August 1st, 2001, 08:12 AM
rharder's Avatar
Do not read this sign.
 
Join Date: Mar 2001
Location: Virginia, USA
Posts: 1,188
Thanks: 0
Thanked 2 Times in 2 Posts
rharder is on a distinguished road
Arg! Twice as slow as Pentium...

Argh! This is frustrating, and I wonder how much of it has to do with the way Objective-C messages are passed around in Cocoa:

I have a random number generator (a good one with 10^57 cycle length!), and I timed how long it took to generate one billion random numbers between zero and one.

On my work's 733 Mhz Pentium III with Yellow Box for Windows NT it took 6.8 minutes.

On my PowerBook G4 with Mac OS X 10.0.4 it took 12.4 minutes.

Where's all the extra slow-down coming from? Even if the chips' architectures were not major players, you'd only expect a 5/7 relationship in performance.

No AltiVec can be used with the RNG's double and long calculations.

Very odd.

-Rob

__________________
There are only 10 kinds of people in the world:
Those who understand binary, and those who don't.
Reply With Quote
  #2  
Old August 1st, 2001, 11:56 AM
knighthawk's Avatar
Registered User
 
Join Date: Jul 2001
Location: Los Angeles, CA
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
knighthawk is on a distinguished road
Is the program a Command Line one, or is it a GUI. Do you think Aqua has anything to do with the performance hits?

Maybe when 10.1 is released it will score better.
Reply With Quote
  #3  
Old August 1st, 2001, 01:51 PM
rharder's Avatar
Do not read this sign.
 
Join Date: Mar 2001
Location: Virginia, USA
Posts: 1,188
Thanks: 0
Thanked 2 Times in 2 Posts
rharder is on a distinguished road
It's GUI. It consists of a button that says Go. Then there's a for loop that loops one billion times and generates random numbers. They're just generated--I don't even do anything with them.

-Rob
__________________
There are only 10 kinds of people in the world:
Those who understand binary, and those who don't.
Reply With Quote
  #4  
Old August 1st, 2001, 05:14 PM
.dev.lqd's Avatar
Angry Member
 
Join Date: Apr 2001
Location: Rochester, NY
Posts: 394
Thanks: 0
Thanked 0 Times in 0 Posts
.dev.lqd is on a distinguished road
This is an absolute stab in the dark. I'm not sure how the NT box would be generating random numbers, but in the very least my OpenBSD box reseeds an "entropy pool" with presumedly erratic data from network latency, serial inputs, system loads, etc. As OSX has some BSD roots (although I believed that was mostly in the network arena) is it possible that OSX is being slowed down because it's constantly refilling this entropy pool, and the NT box is just chucking out the numbers?

Even if this were the case, you can agree this is a fairly narrow performance niche to fill hehehe.

I can think of a thousand facts that would make this seem like a ridiculous idea, so I'll hush now. It was just a thought.
-stephen
Reply With Quote
  #5  
Old August 1st, 2001, 06:12 PM
knighthawk's Avatar
Registered User
 
Join Date: Jul 2001
Location: Los Angeles, CA
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
knighthawk is on a distinguished road
You know, that leads me to another thought...

Might be that if you ran the program as root (different priority level) it would perform better.

Have you benchmarked it on your desktop machine? Maybe it is a powerbook issue (slower clocks if using battary or something like that).
Reply With Quote
  #6  
Old August 1st, 2001, 07:58 PM
rharder's Avatar
Do not read this sign.
 
Join Date: Mar 2001
Location: Virginia, USA
Posts: 1,188
Thanks: 0
Thanked 2 Times in 2 Posts
rharder is on a distinguished road
I'm not using the built-in RNG. It's a new one that's got much better properties and a much longer cycle length. It's processing consists of a bunch of addition and multiplication of doubles.

The two programs are identical, both running under ProjectBuilder, one on Windows NT, one on Mac OS X.

I could try running as root. Aside from the rumor that 'nice' and thread priorities aren't implemented, I'd be pretty upset to learn that I have to run code as root in order to get good performance! This is probably not it, though I'll give it a shot for troubleshooting's sake.

It seems as if the Objective-C message-passing has way too much overhead on OS X. This is surprising, seeing that Cocoa has been around under other names for at least a decade (and has no problems as Yellow Box). These kinks should have been ironed out years ago, if in fact these "kinks" are what's causing the terrible performance.

Still, one good lesson to take from this (which we all should have known anyway):

    Don't use Objective-C messages for performance-critical code.

Sure, use it to construct your app and be a wrapper, but for heavy math and such, use C/C++ where the lower overhead is the more important trait.

Cheers.

-Rob
__________________
There are only 10 kinds of people in the world:
Those who understand binary, and those who don't.
Reply With Quote
  #7  
Old August 2nd, 2001, 07:33 AM
Fahrvergnuugen's Avatar
I am the law!
 
Join Date: Apr 2001
Location: Galway, NY
Posts: 1,009
Thanks: 0
Thanked 0 Times in 0 Posts
Fahrvergnuugen is on a distinguished road
I decided to run a test myself using PHP rather than C [which is WAY slower by the way]. The problem with my test is that the 4 test machines are not all running the same versions of PHP. When I upgrade PHP on my G4, I will post the execution time decrease if any.

Reatta: dual 733MHz PIII, 512MB RAM, PHP 4.0.6: Did nothing in 1.0672010183334 seconds

Delorean: single 733MHz PIII, 256MB RAM, PHP 4.0.6: Did nothing in 1.0971649885178 seconds

[PHP must NOT be multi threaded??]

Immaculata: single 400MHz PII, 256MB RAM, PHP 4.0.5: Did nothing in 1.5302710533142 seconds

Darklotus: Dual 500MHz G4, 1GB RAM, PHP 4.0.4pl1: Did nothing in 2.8723210096359 seconds


Here is the code in case you would like to try it out:
Code:
<?

function getmicrotime(){ 
    list($usec, $sec) = explode(" ",microtime()); 
    return ((float)$usec + (float)$sec); 
} 

$time_start = getmicrotime();
    
for ($i=0; $i < 1000000; $i++){
    //do nothing, 1000000 times
}

$time_end = getmicrotime();
$time = $time_end - $time_start;

echo "Did nothing in $time seconds";

?>
__________________
-Paul Wieland______________
http://www.sickdimension.com
Dual G5 2.0Ghz / 2.5GB Ram / 620 GB HD / 23" CD
Reply With Quote
  #8  
Old August 2nd, 2001, 10:18 AM
knighthawk's Avatar
Registered User
 
Join Date: Jul 2001
Location: Los Angeles, CA
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
knighthawk is on a distinguished road
An Idea...

rharder:

you mentioned that you did nothing with the random numbers that you were generating. If you are going to wait minutes for the results, why don't you just SUM and average the random numbers.

At the end of the loop, assuming you are generating numbers between 0 and 1, you should get an average of "0.5".

Please post your results so we can see.
Reply With Quote
Reply

Bookmarks

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 Off
Pingbacks are Off
Refbacks are Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
internet connection really slow. please help! kidxsai Networking & Compatibility 6 February 27th, 2009 06:56 AM
really really slow speeds on a LAN.... reverseswim Networking & Compatibility 7 May 24th, 2003 11:38 AM
IE slow to respond in 10.1? Unresponsive? djubelirer Mac OS X System & Mac Software 2 October 5th, 2001 12:26 PM
OSX and iBook: slow forever? soupandtea Apple News, Rumors & Discussion 4 July 19th, 2001 03:53 PM
Why downloading is so slow compared to Windows??? troydugger Mac OS X System & Mac Software 6 May 27th, 2001 04:10 PM


All times are GMT -5. The time now is 07:14 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
Copyright 2000-2010 DigitalCrowd, Inc.