Re: do compilers make a difference OR why is my perl slow

2002-12-16 Thread Dan Sugalski
At 11:05 AM -0600 12/16/02, Puneet Kishor wrote:

I recently read that gcc is a dog. (I am heavily paraphrasing for 
the sake of brevity). The same program compiled with a different 
compiler ran significantly faster.

Yes, it is, though it's getting less dog-like as time goes on. 
Generally when comparing GCC to $paid_for_compiler, GCC will lose, 
often by a lot. GCC, at least through version 2.x, was remarkably 
Lisp-like internally, which made for some interesting impedance 
issues when the target CPU wasn't mostly a stack-machine. You'll see 
more of a performance hit when targetting register rich architectures 
(like the PPC) than you will on register starved architectures like 
the x86.

Having said that, I don't know about the internals of the 3.x series of GCC.

That specific article itself is irrelevant. But what inquiring (and 
clueless) minds want to know, is my OS X perl slower that my 
ActiveState perl because of the compilers used to compile the perl 
binary in the first place.

While yes, the numbers you got do *not* mean anything, unfortunately. 
Not because of compiler differences but because of hardware 
differences. Laptops aren't optimized for speed, they're optimized 
for power usage and size. This adds in a not-insignificant amount of 
overhead--with a disk-heavy benchmark I wouldn't at all be surprised 
to see a factor of two, three or four speed hit for the laptop, 
especially if you were running the laptop on battery power.
--
Dan

--"it's like this"---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk


Re: do compilers make a difference OR why is my perl slow

2002-12-16 Thread Kee Hinckley
At 11:05 AM -0600 12/16/02, Puneet Kishor wrote:

duplicates then sorted results, and wrote 'em out to another file. 
The only catch -- the original file was 145 Mb with close to 3.5 
million lines (I created that by simply cat-in >> the same file over 
and over again to an output file until my fingers got tired). The 
end result was a svelte, 600+ line file, about 11 kb.

The operation took about 122 secs on the Windows machine, and 299 
seconds on the iBook.

There's another variable to keep in mind--disk speed.  Especially on 
laptops you may find that the disk speed is significantly slower.  I 
see it particularly whenever I do something like "make install" in 
one of my software projects.  On a linux box it zips along.  On my 
laptop it crawls along running each one.  Some of that may be file 
system, but I actually use UFS for a lot of my laptop work.  I 
suspect that fundamentally it's just a lot slower drive.
--

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.


Re: do compilers make a difference OR why is my perl slow

2002-12-16 Thread Sherm Pendley
On Monday, December 16, 2002, at 12:05 PM, Puneet Kishor wrote:


Yes, the iBook CPU is 200 Mhz slower, and god only knows how we can 
compare a P3 to G3, but 2.5 times the time taken is a bit much. Coming 
back to my initial assertion -- Could some of this be attributed to the 
way the perl binary is compiled?

I doubt it. It's very true that the "generic" distribution of GCC is not 
well optimized for the PowerPC, but Apple has done lots of work in that 
area.

Given the size of the input file, I'd guess that your script is I/O 
bound. If I recall correctly, the iBook uses 66MB/s IDE, and ships with 
a pokey hard drive - 4200RPM or thereabouts. If your PC is a desktop 
machine, its HD is probably either 100MB/s or 133MB/s, and either 5400 
or 7200 RPM. The difference in file I/O performance is considerable.

A couple of things you could try, to narrow down the source of the 
difference:

Try re-running the test without the filtering and sorting; that is, just 
time how long it takes on each machine, just to read in the source file.

If you have access to an external FireWire drive, you could try running 
the test on that.

It's also worth noting that your test took over two minutes on the PC - 
depending on your power settings, your iBook may have spun down its 
internal HD while your script was filtering and sorting records. If 
that's the case, it would have had to start the HD back up before 
writing the output, causing a significant delay.

sherm--

UNIX: Where /sbin/init is Job 1.



Re: do compilers make a difference OR why is my perl slow

2002-12-16 Thread Chris Devers
On Mon, 16 Dec 2002, Puneet Kishor wrote:

> Yes, the iBook CPU is 200 Mhz slower, and god only knows how we can
> compare a P3 to G3, but 2.5 times the time taken is a bit much. Coming
> back to my initial assertion -- Could some of this be attributed to the
> way the perl binary is compiled?

There's too many variables here to draw any meaningful conclusions. Rather
than compare the PC to the Mac, try to compare just GCC to $other_compiler
by, for example, comparing two different versions of Perl on just the PC.

My understanding is that ActiveState compiles their software against VC++,
while my assumption is that Cygwin probably compiles theirs against GCC.
So it try that way then: install the ActiveState & Cygwin versions of Perl
on your PC (and for laughs, maybe install Cygwin's development tools and
build your own copy of Perl against their version of GCC, just so you
don't have to wonder how they built theirs), Then repeat your test (and
maybe others) comparing the two versions of Perl on the same machine.

If you do it that way, you'll eliminate any differences between processor
architectures & speeds, ram quantity & speed, operating system quirks,
etc.

I'd be interested in the results of such a test, actually...


-- 
Chris Devers[EMAIL PROTECTED]

In every hierarchy the cream rises until it sours.
-- Dr. Laurence J. Peter



do compilers make a difference OR why is my perl slow

2002-12-16 Thread Puneet Kishor
Folks,

I recently read that gcc is a dog. (I am heavily paraphrasing for the 
sake of brevity). The same program compiled with a different compiler 
ran significantly faster.

That specific article itself is irrelevant. But what inquiring (and 
clueless) minds want to know, is my OS X perl slower that my ActiveState 
perl because of the compilers used to compile the perl binary in the 
first place. Yes, I know comparing different platforms is tricky -- cpu 
speed, ram, cpu architecture, other daemons running, etc. But, in an 
overall sense of things -- does gcc make things slower?

In some spare time I did some empirical testing using the same script on 
perl 5.6.1 on Win2k (PIII/833 Mhz/512 Mb ram/apache, and no other 
significant daemons) versus perl 5.6.1 on OS X (G3/600 Mhz/640 Mb 
ram/apache, and no other significant daemons). I started with a file 
with email addresses (one per line), many being duplicates. A small perl 
script first removed the duplicates then sorted results, and wrote 'em 
out to another file. The only catch -- the original file was 145 Mb with 
close to 3.5 million lines (I created that by simply cat-in >> the same 
file over and over again to an output file until my fingers got tired). 
The end result was a svelte, 600+ line file, about 11 kb.

The operation took about 122 secs on the Windows machine, and 299 
seconds on the iBook.

Yes, the iBook CPU is 200 Mhz slower, and god only knows how we can 
compare a P3 to G3, but 2.5 times the time taken is a bit much. Coming 
back to my initial assertion -- Could some of this be attributed to the 
way the perl binary is compiled?


The test script follows. The only difference on the platforms was the 
shebang line.

I used the following script (some code is mine, some from the cookbook). 
I used my own crude benchmark.

#!c:\perl\bin\perl.exe -w
my $start = time();

my $file = "c:/htdocs/testers/dupes/dupes2.txt";

open IF, $file or die $!;
open OF, ">c:/htdocs/testers/dupes/filewithoutdupes.txt" or die $!;

my @list;
push(@list, $_) while ();

my %seen = ();
my @uniq;
foreach my $item (@list) {
push(@uniq, $item) unless $seen{$item}++;
}

my @uniqsorted = sort @uniq;
print OF @uniqsorted;

close IF;
close OF;
my $end = time();
my $dur = $end - $start;
print "This took $dur seconds\n";