[Dbix-class] DBIx::Class::Fixtures speedup

Matt S Trout dbix-class at trout.me.uk
Wed Apr 23 14:43:27 BST 2008


On Wed, Apr 23, 2008 at 01:03:22PM +0100, Drew Taylor wrote:
> On Wed, Apr 23, 2008 at 12:43 PM, luke saunders
> <luke at shadowcatsystems.co.uk> wrote:
> > On Wed, Apr 23, 2008 at 12:14 PM, Drew Taylor <taylor.andrew.j at gmail.com> wrote:
> >
> > > I'm using Fixtures in my app, and am overall pleased with it. But I
> >  >  now have a couple thousand fixture items which are imported, and
> >  >  that's taking upwards of 1min+. Out of curiosity I commented out the
> >  >  creation of the tmp_fixtures_dir and just read from fixtures_dir. I
> >  >  shaved my populate() time in approximately half. What's the reasoning
> >  >  for the tmp dir? Safety in case anything goes wrong? For me, it's just
> >  >  a lot of wasted IOs and time. :-) Luke, any objections if I remove
> >  >  this?
> >  >
> >
> >  The tmp directory is used so that if someone dumps while you are
> >  populating the populate is unaffected. Since this is an issue for some
> >  people I'd suggest making the tmp directory thing configurable,
> >  probably in the call to ->new. Normally if the fixtures are on a local
> >  drive using a tmp directory doesn't take too long so I'd prefer to
> >  keep it the default.
> 
> Ahhh, that makes sense. The copy doesn't take _that_ long (I'm
> guessing around 30-60 seconds for my current record set), but when I
> want to do quick, successive test runs it adds up rather quickly.

What if you used link() instead of a copy?

Or just make the dump code make the tmp dir, and populate open a file handle
to everything in advance so you don't have to worry about paths changing
under you?

Either should be no more prone to races than the current approach and much
much faster for everybody :)

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list