On Thu, Aug 29, 2002 at 04:31:14PM -0400, Dan Sugalski wrote: > I ran some quick time tests on the GC, and hashes are relatively > expensive to GC, relative to other things. (They're an order of > magnitude slower than perlstrings, and two orders of magitude slower > than perlints) They're slow enough that I'd like to take a look at > them to see if perhaps there's a way to have less GC overhead... > --
PerlStrings are scanned using the PMC_is_buffer_ptr_FLAG; PerlInts don't need to get scanned at all. Neither of them has any possibility of containing other PMCs or Buffers, so it's not really a fair comparison. Arrays or PerlArrays would be a slightly better comparison, because at least they contain other stuff. But still, they get scanned via PMC_is_buffer_ptr_FLAG and PMC_is_PMC_ptr_FLAG. PerlHash fundamentally needs a custom mark routine. So at the very least, I think you need to compare against something with a custom mark(). Then we'll know how much improvement is possible. I would recommend the Key PMC for now, since its mark() routine is about as simple as you'll be able to get. One way to get a speedup, though, is to discard the value union and only allow hashes to contain PMCs. I don't think anything is really using the other possibilities anyway, though I might be wrong. (And I have no idea whether anything would actually speed up...)