threads::lite and the chameneoses
The Challenge
Last week on stackoverflow I came across an interesting challenge. Since my new module threads::lite seems to have stabilized enough for such a task I decided to to port the erlang submission to it (while using some helper routines from the perl submission). The porting was a fairly straightforward process that resulted in a pleasantly readable program (specially when compared to the other entry).
Then I ran it. It ran almost 6 times as slow as the other perl program!
Reason enough to profile it and see what was going on. Renodino's comment proved to be quite accurate: Storable and locking seemed to be the main culprits.
To tackle the first issue I added a simple but effective feature: if a message contains only simple elements (no references or undefined values), it is pack
ed instead of frozen.