Adi Fairbank wrote:
>
> I am trying to squeeze more performance out of my persistent session cache. In
> my application, the Storable image size of my sessions can grow upwards of
> 100-200K. It can take on the order of 200ms for Storable to deserialize and
> serialize this on my (lousy) hardware.
>
Its a different approach, but I use simple MLDBM + SDBM_File
when possible, as its really fast for small records, but it has
that 1024 byte limit per record! I am releasing a wrapper
to CPAN ( on its way now ) called MLDBM::Sync that handles
concurrent locking & i/o flushing for you. One advantage
of this approach is that your session state will persist
through a server reboot if its written to disk.
I also wrote a wrapper for SDBM_File called MLDBM::Sync::SDBM_File
that overcomes the 1024 byte limit per record. The below
numbers were for a benchmark on my dual PIII 450, linux 2.2.14,
SCSI raid-1 ext2 fs mounted async. The benchmark can be found
in the MLDBM::Sync package in the bench directory once it makes
it to CPAN.
With MLDBM ( perldoc MLDBM ) you can use Storable or
XS Data::Dumper method for serialization as well as
various DBMs.
--Josh
=== INSERT OF 50 BYTE RECORDS ===
Time for 100 write/read's for SDBM_File 0.12 seconds
12288 bytes
Time for 100 write/read's for MLDBM::Sync::SDBM_File 0.14 seconds
12288 bytes
Time for 100 write/read's for GDBM_File 2.07 seconds
18066 bytes
Time for 100 write/read's for DB_File 2.48 seconds
20480 bytes
=== INSERT OF 500 BYTE RECORDS ===
Time for 100 write/read's for SDBM_File 0.21 seconds
658432 bytes
Time for 100 write/read's for MLDBM::Sync::SDBM_File 0.51 seconds
135168 bytes
Time for 100 write/read's for GDBM_File 2.29 seconds
63472 bytes
Time for 100 write/read's for DB_File 2.44 seconds
114688 bytes
=== INSERT OF 5000 BYTE RECORDS ===
(skipping test for SDBM_File 1024 byte limit)
Time for 100 write/read's for MLDBM::Sync::SDBM_File 1.30 seconds
2101248 bytes
Time for 100 write/read's for GDBM_File 2.55 seconds
832400 bytes
Time for 100 write/read's for DB_File 3.27 seconds
839680 bytes
=== INSERT OF 20000 BYTE RECORDS ===
(skipping test for SDBM_File 1024 byte limit)
Time for 100 write/read's for MLDBM::Sync::SDBM_File 4.54 seconds
13162496 bytes
Time for 100 write/read's for GDBM_File 5.39 seconds
2063912 bytes
Time for 100 write/read's for DB_File 4.79 seconds
2068480 bytes