Thanks, but I'm looking for something a bit more chunky that reduces the number of times that Perl will call malloc
250,000 calls to
keys %myhash = 120;
is not much better than just preallocating the array and allowing the individual hashes to get created one at a time. | [reply] [d/l] |
The old C trick I used to see was to calculate the total malloc arena size needed, then malloc one huge chunk that size at startup and immediately free it. The idea was that the smaller mallocs would then use that existing huge malloc arena. Since the actual process memory, gotten (on UNIX) via sbrk is one way only -- you can't give it back -- malloc maintains free space in its own internal arena. This approach supposedly then traded off all those expensive small system calls with one up front.
In practice, I saw mixed results with this. And I'm sure malloc algorithms have changed so it may mean absolutely nothing today even if you can figure out how to translate that to Perl. Maybe it would be better to use an alternate malloc package when building Perl?
| [reply] |
Well, Perl isn't C. Maybe you should consider using a different
datastructure.
Abigail
| [reply] |
| [reply] [d/l] [select] |