some questions/optimization ideas

Brad Fitzpatrick brad at danga.com
Wed Nov 8 00:56:58 UTC 2006


Good find on the POSIX imports.  In general I hate cluttering my namespace
with imports and tend to put empty parens after all my 'use' lines, but I
guess I forgot during the crazy refactoring....

I'll clean it up.  Thanks!

(as for ->ping, I'll hold until the DB abstraction work, but then,
yeah...)


On Tue, 7 Nov 2006, Hill, Greg wrote:

> I'm starting to familiarize myself with the code a bit, as I'll be
> working on integrating memcached into mogilefs (Earl, my boss, emailed
> the list previously about that).  Anyway, I just noticed something that
> you might want to reconsider.  In mogilefsd, you have:
>
>
>
> use POSIX;
>
>
>
> The POSIX module exports all of its functions by default, adding over
> 1MB to each process (discovered this when profiling memory usage at a
> previous employer).  It'd be better to specify which functions you want
> to import, or even better to import none and just refer to them using
> the namespace.
>
>
>
> 1MB isn't really a huge deal, but considering you probably only make use
> of a few POSIX functions, it's quite wasteful. (in the case where I
> discovered it, we were only using 2 functions).
>
>
>
> Another thing I noticed, albeit not really important:
>
>
>
> In 'validate_dbh' you have:
>
>
>
>         my $id = $dbh->selectrow_array("SELECT CONNECTION_ID()");
>
>         if (! $id) {
>
>             # handle's dead.  don't use it.  (MySQL-ism above)
>
>             undef $dbh;
>
>         }
>
>
>
> While you could just do:
>
> if (! $dbh->ping) {
>             undef $dbh;
>
> }
>
>
>
> That would make it more database agnostic.  Or maybe you had a good
> reason for doing it the other way.
>
>
>
> Maybe you don't care about either of those, but I thought I'd pass them
> along.
>
>
>
> Greg
>
>


More information about the mogilefs mailing list