No, and if you think about it, it'd be pretty complex to do since
"loading relationships" really means creating new methods and loading
other classes which themselves have relationships to other classes and
will need methods created and so on. It's pretty easy to end up
triggering a massive class load and method creation spree with, say, a
single Manager query.
Even for 500 classes, a 15-second load time seems way too long. Have
you profiled it? What's the bottleneck? Disk? CPU?
-John
The methods are created using anonymous subs that act as closures,
capturing values of surrounding lexical variables I'm not aware of
any good way to serialize such subs into source code, though I believe
there are some experimental approaches on CPAN.
> Initially we were using Class::Autouse->autouse() for the set of table-
> based classes, and this led to the 15 s runtime on first use of the
> Event class, and almost the entirety of this time happening during
> Metaclass->add_relationship(). I was perusing your Metadata.pm code
> and I'm wondering if it doesn't play nicely with Class::Autouse
> because autouse registers the potential classes in the same place that
> Rose looks to see if the class is already loaded.
Which place is that? %INC? (I'm not familiar with Class::Autouse.)
> When we simplified our test, removed autouse, and we just used a
> single "use" statement for the Event class, it takes 5 s, which is
> okay for our persistent applications but not ideal for the arsenal of
> quick response programs and scripts.
RDBO is not a good fit for "non-persistent" environments where you
need very fast process startup time. Its design is slanted heavily
towards doing a lot upfront (and trading memory usage for speed) which
is a good fit for persistent, load-in-parent-then-fork environments
like mod_perl. There are, however, ways to get this same kind of
performance outside of mod_perl by wrapping your scripts in a
persistence layer so they, too, only have to load once. I forget the
modules, but I think Perrin(?) posted a few to this list earlier. If
not, maybe search or ask on stackoverflow.com.
> This test does not include overhead to connect to the database. When we
> profile this test script, we find that 700 calls to
> retry_deferred_foreign_keys() inclusively accounts for roughly 1/2 of the
> total time, and .87s not including function calls it makes; 140,000 calls to
> meta() and dynamic functions in MakeMethods::Generic appears to take over 2s
> as well. Although we use nytprof, I have included the output from DProf since
> it is easier for your to view it. Most of the methods below are also listed
> on the 'top 10' list, but the calculated time is actually quite different.
Those call count numbers don't surprise me, but there could be room
for some optimization. Have you looked into the relevant code?
-John