So, now that I know why my picpage module is actually running slowly, I need to do something about it. (Originally Startup cost, CGI performance, continued in CGI to Apache::Registry, or to mod_perl

The module displays one photo from a photo gallery, with title, description, comments, navigation links to previous and next photos in the gallery, that kind of thing. It's to run in a non-database environment.

Currently it gets most information from a YAML file written out by the galpage script, which generates the thumbnail page for the gallery (not dynamically) after reading up the previous YAML file, looking at all the image files in the directory, checking for .name and .info files associated with the image files, and generally thrashing around a lot.

Part of the complexity is dictated by galpage being intended to replace a previous dynamic solution; it needs to read the same files that used, and incorporate them into the YAML for the future. It's also necessary for me to edit the YAML file manually -- the new way of doing things is to run galpage on a directory with just the image files, then edit into the YAML file the titles and such. This, I might add, is a solution intended for me, not something to be turned over later to users.

In large directories, it turns out that reading the YAML is the largest component of the time spent by picpage (2.5 seconds, against the next largest chunk being smaller than .01).

I'm trying to reject the solution of writing a binary file (which should then be readable with far less parsing), because that would require creating an application to do that manual editing in the binary file, which would be a huge amount of work and provide a much less pleasant interface to editing the data in the file (I'm an emacs user; 'nuff said).

So I see two classes of solutions:

  1. Find a human-editable way to store Perl data structures with better read-in performance than YAML.
  2. Have picpage (which is now running in mod_perl) cache the YAML data once read in, so near-by references to other pictures on the same page won't be slow. Since this is for web work, this caching would have to be shared among processes.

So, are there modules to suggest? I remember that HTML::Mason has a very nice caching system, which isn't actually specific to Mason, for example.


In reply to Big config file reading, or cross-process caching mechanism by dd-b

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.