Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.
As expected, AI::Life::World is ridiculously slow. The C version of the program can run a million iterations in a few minutes. The Perl version takes a few days. There are many reasons for that and I've got a good handle on them, but it's going to be a long, tough slog to get this program performing at an acceptable level.
Amongst other things, this has reconfirmed my opinion that overloading accessors to also be mutators is a bad idea ($o->foo and $o->foo(7)). There's extra logic in the method and if I just separate the two (having a $o->set_foo), I get to avoid that. I also intend to get rid of Class::Struct and craft all of the methods by hand (or perhaps building methods at startup) to give me a bit more control over the performance of the system. I also need to figure out how to improve the speed at which the animals "see". The $agent->look method is taking about 25% of the entire run of the program.
The most radical idea I have, though, is to skip all data validation. I know this sounds terrible, but my thought is to use Devel::Profile to ensure that I am testing almost 100% of the program. From there, I'll start tracing the data flows and see if there's an entry point I can do data validation at and the just trust that it will work out internally. I've always admired tightrope walkers who don't use a net (I've also thought they were pretty stupid, too).
Class::Meta (Score:2)
You might want to check out my Class::Meta module. It does accessor and mutator generation at startup and data type validation. You can optionally turn off data type validation for production code, however, but provide your own simple code reference to generate accessors and mutators. I've been meaning to add this as a standard, but tuits are in short demand at the moment.
I also want to add "Semi Affordance" accessors, e.g.,
foo()andset_foo(). The current options are Perl-style accesors (foo()) and "AffRe:Class::Meta (Score:2)
That sounds interesting, but I have to confess that I want something as fast as this:
I confess that this makes me cringe, but again, this software is so incredibly slow that I'm looking at extrame measures.
Re:Class::Meta (Score:1)
Re:Class::Meta (Score:2)
You're hurtin' me, man, you're hurtin' me! I've been painfully aware of this. Currently, nothing needs OO, but switching away from is daunting and will complicate further plans. I'm going to sleep poorly tonight, thanks to your suggestion :/
Re:Class::Meta (Score:2)
Well then perhaps you can fall back on direct hash access for your objects:
Yeah, I hate it too, but it's the fastest way to do it and still have "objects" of a sort.
--David
Re:Class::Meta (Score:2)
Array lookups are typically faster than hash lookups. That's why I avoided the blessed hashes.
Re:Class::Meta (Score:1)
Re:Class::Meta (Score:2)
Curiously, that's sort of an idea I considered a couple of days ago [perl.org] when I wrote "maybe it's time for me to start eyeing Parrot for some of this." One one hand, I'm doing this specifically in Perl so that any Perl programmer can pick it up and see how this stuff works. On the other hand, if a simulation "week" starts approaching real-time, ain't no one gonna wanna play. I suppose that Parrot would be an interesting compromise.
Re:Class::Meta (Score:1)
Re:Class::Meta (Score:2)
chromatic was mentioning that yesterday at his Parrot/SDL talk. That's interesting. Hmmm ... maybe I don't need free time after all :)
Re:Class::Meta (Score:1)
Patience; as soon as the copyeditor finishes with it in a couple of hours, I'll publish the link.
Re:Class::Meta (Score:1)
It's a conspiracy, I tell you! (or is that "its"? Hrm...)
Re:Class::Meta (Score:2)
A writer and his editor were crawling through the desert, dying of thirst, when they discovers a small pond. Overjoyed, the writer starts drinking deeply when he notices the editor relieving himself in the water.
"What the heck do you think you're doing?" screamed the writer.
"Improving it."
(with sincerest apologies to chromatic :)
Re:Class::Meta (Score:2)
Sheesh. There's something supremely ironic about making a typo while making fun of editors.
Re:Class::Meta (Score:2)
Re:Class::Meta (Score:2)
set_mutators in the next week.David