http://qs1969.pair.com?node_id=1216775


in reply to Re^3: Inline::C on Windows: how to improve performance of compiled code?
in thread Inline::C on Windows: how to improve performance of compiled code?

ikegami, yes, both Perls are threaded 5.26 (it's in OP).

syphilis, thanks a lot for your research. I still hope, C code can be compiled into "faster version" i.e. with speed on par with unthreaded or Linux Perls. Core XS modules don't run 2 times slower on Windows.

Here's a little experiment. The hv_store (Hash::Util) is documented as

hv_store() is from Array::RefElem, Copyright 2000 Gisle Aas

(BTW, as an aside, some funny and interesting things can be done with aliases stored as aggregate elements, it seems references overshadowed this feature which has been there for free for decades, no new experimental "refaliasing" required for that (it's not surprising since they are "aggregate elements", not regular variables). But you know all that.)

So, a couple weeks ago I accidentally found Hash::Util::hv_store is almost exactly 2 times faster than Array::RefElem::hv_store. I thought it strange but didn't investigate it then. Now:

>perl -MTime::HiRes=time -MHash::Util=hv_store -wE"%h=();$t=time;hv_st +ore(%h,'foo',42) for 1..1e8;say time-$t" 10.8255708217621 >perl -MTime::HiRes=time -MArray::RefElem=hv_store -wE"%h=();$t=time;h +v_store(%h,'foo',42) for 1..1e8;say time-$t" 20.3003470897675 $ perl -MTime::HiRes=time -MHash::Util=hv_store -wE'%h=();$t=time;hv_s +tore(%h,"foo",42) for 1..1e8;say time-$t' 10.5545630455017 $ perl -MTime::HiRes=time -MArray::RefElem=hv_store -wE'%h=();$t=time; +hv_store(%h,"foo",42) for 1..1e8;say time-$t' 12.1946179866791

The question is whether it's possible to compile anything (Array::RefElem or inline C) to be fast on threaded Win32 Perl. The fact that e.g. Hash::Util exists suggests the answer is "yes". But how? :)