File-Write-Rotate
view release on metacpan or search on metacpan
rotator process like the Unix logrotate utility (which when accidentally
disabled or misconfigured will cause your logs to stop being rotated and
grow indefinitely).
What is the downside of using FWR (and LDFR)?
Mainly (significant) performance overhead. At (almost) every "write()",
FWR needs to check file sizes and/or dates for rotation. Under default
configuration (where "lock_mode" is "write"), it also performs locking
on each "write()" to make it safe to use with multiple processes. Below
is a casual benchmark to give a sense of the overhead, tested on my Core
i5-2400 3.1GHz desktop:
Writing lines in the size of ~ 200 bytes, raw writing to disk (SSD) has
the speed of around 3.4mil/s, while using FWR it goes down to around
~13k/s. Using "lock_mode" "none" or "exclusive", the speed is ~52k/s.
However, this is not something you'll notice or need to worry about
unless you're writing near that speed.
If you need more speed, you can try setting "rotate_probability" which
will cause FWR to only check for rotation probabilistically, e.g. if you
lib/File/Write/Rotate.pm view on Meta::CPAN
Mainly convenience and low maintenance. You no longer need a separate rotator
process like the Unix B<logrotate> utility (which when accidentally disabled or
misconfigured will cause your logs to stop being rotated and grow indefinitely).
=head2 What is the downside of using FWR (and LDFR)?
Mainly (significant) performance overhead. At (almost) every C<write()>, FWR
needs to check file sizes and/or dates for rotation. Under default configuration
(where C<lock_mode> is C<write>), it also performs locking on each C<write()> to
make it safe to use with multiple processes. Below is a casual benchmark to give
a sense of the overhead, tested on my Core i5-2400 3.1GHz desktop:
Writing lines in the size of ~ 200 bytes, raw writing to disk (SSD) has the
speed of around 3.4mil/s, while using FWR it goes down to around ~13k/s. Using
C<lock_mode> C<none> or C<exclusive>, the speed is ~52k/s.
However, this is not something you'll notice or need to worry about unless
you're writing near that speed.
If you need more speed, you can try setting C<rotate_probability> which will
cause FWR to only check for rotation probabilistically, e.g. if you set this to
( run in 0.445 second using v1.01-cache-2.11-cpan-299005ec8e3 )