in reply to Big config file reading, or cross-process caching mechanism

Don't use YAML. Use Storable, which is much faster.

If you need manual edits, just write a quicky YAML-to-Storable and Storable-to-YAML tweaker.

If that's still not fast enough, use DBD::SQLite, and then you can extract from the file only exactly what you need.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on •Re: Big config file reading, or cross-process caching mechanism

Replies are listed 'Best First'.
Re: •Re: Big config file reading, or cross-process caching mechanism
by dd-b (Pilgrim) on Jan 17, 2004 at 19:50 UTC

    I see what you mean:

    Reading yaml took 1074368876.73842 to 1074368878.98043, 2.24200582504272
    Reading storable took 1074368879.0243 to 1074368879.04725, 0.0229549407958984
    

    So that's a possibility. I'm still interested in the caching possibility too, though.

      It's easy to do a quick cache using MLDBM::Sync (which uses Storable for serialization and handles locking for you). This is faster than what Mason currently uses. You could keep a "last modified" time in your cache data and stat the YAML file to make sure your cache is up to date. If the YAML file is newer than the cache, read it and write the data to cache. However, a cache won't solve the problem if you actually have to write the YAML from your program as well as read it.