At 2:38 PM -0800 12/27/03, Joe Wilson wrote:
--- Luke Palmer <[EMAIL PROTECTED]> wrote:
 Joe Wilson writes:
 > Dan Sugalski:
 > > 2) Parrot's Array and SArray values all accept mixed-type data, which
 > > perl's arrays do *not* do, and as such have some extra speed hits
 > > that perl arrays don't.
 >
 > What do you mean?
 > Perl's arrays do indeed accept mixed data types (see example below).

No, they don't. They are arrays of PerlScalars only.

I assumed Dan meant strings, floats and integers were mixed data types because this is what my benchmark programs demonstrated.

I did, but perl's arrays don't do that. Perl 5, internally, has a single scalar data type, the SV, and that's all that you can put into arrays or hashes. When you do this in perl:


$foo[12] = 99;

You're actually putting an SV into slot 12 of foo, with an integer value of 99. It's the equivalent of storing a PerlInt PMC with a value of 99.

SArray and Array PMCs, in addition to being sparse (which has some overhead), allow you to really store PMC *, STRING *, INTVAL, and NUMVAL entries, which means that each slot in an SArray and Array needs to have a flag on it that says what data type's in each slot. Most of the code to handle this lives in list.c and, honestly, there's a lot of overhead. For the problem it solves--having a mixed-type sparse array--it's just fine, but that's not what we need in this case, so the overhead is just too darned excessive.

What we need to do is get SArray a lot more efficient, so it holds just PMCs and doesn't do any of the sparse stuff that's done now. That'll tighten things up a lot, and I think should get us more in line with how perl's behaving and how we want to be behaving.

Also, you might want to make sure you've built Parrot with optimizations on. By default we don't enable GCC's -O to do any optimization, and that does slow things down a bunch. On the other hand, it makes debugging a whole lot easier. Perl 5 is built with full optimization, so that'll make quite a difference. (Pass the --optimize flag to Configure.pl to enable it, and expect the core ops files to chew massive amounts of RAM and swap while it happens)
--
Dan


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

Reply via email to