[erlang-questions] how to do faster integer operations (was: some language changes)
Roger Larsson
roger.larsson@REDACTED
Wed Jun 6 23:39:34 CEST 2007
On Wednesday 06 June 2007 11:27, Paul Mineiro wrote:
> paraphrasing ok <ok@REDACTED>:
>
> [ a machine width integer type won't help in Erlang because it's
> dynamically typed ... maybe there's another way to speed this up ...
> share the function and we'll see ]
>
> Alright, well, I've isolated a "sufficiently generic" part of the
> computation which is still disappointingly slow (attached). My
> machine can do 100K in circa 1s using hipe compilation; the equivalent
> C is about 2 orders of magnitude faster.
>
> erl
Erlang (BEAM) emulator version 5.5.4 [source] [64-bit] [async-threads:0]
[hipe] [kernel-poll:false]
Eshell V5.5.4 (abort with ^G)
1> c(megahash).
{ok,megahash}
2> megahash:benchmark().
236086
3> megahash:benchmark().
235660
Mine does a lot better (but I have no idea on how fast your CPU is),
notice that I run 64-bit AMD.
D0 = 16#9e3779b9,
I think this code can be a problem the problem might be related to your use
of 32 bit integers - they will not fit since the Erlang uses a tag for dynamic
type handling. With 64-bit processor both the tag and the 32-bits value fit
in one 64-bit register.
> cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 15
model : 47
model name : AMD Athlon(tm) 64 Processor 3500+
stepping : 0
cpu MHz : 1000.000
cache size : 512 KB
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt lm
3dnowext 3dnow up pni lahf_lm
bogomips : 2001.39
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc
More information about the erlang-questions
mailing list