HiPE compilation gives NINE times speed increase!

Peter-Henry Mander erlang@REDACTED
Sat Jan 15 18:19:27 CET 2005

Hi Gurus,

I've made an interesting discovery, I think, and I would like to solicit
your opinions why this code happens to run over NINE TIMES faster when
compiled natively compared to virtual machine BEAM code. The results
below are from a system with a VIA M10000 EPIA motherboard. Not a speedy
machine by modern standards (which is an incentive to write code that
runs fast :-). Can you all please try this code on other platforms to
see if the result is consistent on every one?

My guess is the combined use of the recently updated try-catch statement
and binaries allows for some of the HiPE team's work to really shine in
this example. I found this out by chance, and I would be very interested
if members of the HiPE team can offer programming guidelines to maximise
optimisation in other situations.

Dr. Joe (hi Joe) has stated recently "[...] write your code as
beautifully as possible - and measure - if it's not fast enough then
measure and then optimise." Although I would not claim that the attached
code is anywhere near beautiful, I don't think it's too ugly either. The
last 30 lines or so of prefix.erl are the core of the tokeniser
(extracted from a SIP stack I'm *still* working on. Hi Fredrik :-). All
the rest is just a test cradle with chronometric knobs on.


4> test:test().
TimeScan 13027457  TimeParse 240057  Size 4063232
TimeScan 12616897  TimeParse 238838  Size 4063232
TimeScan 12615948  TimeParse 239121  Size 4063232
TimeScan 12606858  TimeParse 239751  Size 4063232
TimeScan 12614551  TimeParse 239600  Size 4063232
          token:   12696342 (  1% Std DV8) ScanTime      239473 (  0% Std DV8) ParseTime    12935815 TotalTime
TimeScan 1332222  TimeParse 229074  Size 4063232
TimeScan 1329588  TimeParse 223404  Size 4063232
TimeScan 1330333  TimeParse 222985  Size 4063232
TimeScan 1329658  TimeParse 223437  Size 4063232
TimeScan 1327399  TimeParse 222689  Size 4063232
          token:    1329840 (  0% Std DV8) ScanTime      224317 (  1% Std DV8) ParseTime     1554157 TotalTime
          token:    9.54727 ScanTimeMult     1.06757 ParseTimeMult

"The Tao of Programming
 flows far away 
 and returns 
 on the wind of morning."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: prefix.erl
Type: application/octet-stream
Size: 2734 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20050115/e32c5843/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.erl
Type: application/octet-stream
Size: 3123 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20050115/e32c5843/attachment-0001.obj>

More information about the erlang-questions mailing list