Data-TimingWheel-Shared
view release on metacpan or search on metacpan
xt/crash_recovery.t view on Meta::CPAN
use Data::TimingWheel::Shared;
# A child cannot finish scheduling+cancelling 2M timers in 50ms; SIGKILL it
# mid-storm while it may hold the write lock, then verify the parent can still
# take the write lock and schedule -- the futex rwlock's dead-owner recovery.
# The anonymous MAP_SHARED mapping is inherited across fork, so parent and child
# contend on the one wheel.
#
# The pool has to outlast the kill window on ANY runner, not just a slow one:
# only the odd ids are cancelled, so the child nets one timer every two
# iterations and a 100_000 pool was 61% consumed in 50ms here -- a 1.7x margin
# that a faster machine closes, and then the child dies of "timer pool is full"
# rather than of our SIGKILL, testing nothing. Size it past the 1M net adds the
# loop can possibly reach. Only touched pages are resident, so the larger
# mapping costs about what the old one did.
my $h = Data::TimingWheel::Shared->new(undef, 256, 1_100_000);
my $pid = fork // die $!;
if (!$pid) {
my $s = 1;
for (1 .. 2_000_000) {
$s = ($s * 1103515245 + 12345) & 0x7fffffff;
( run in 2.015 seconds using v1.01-cache-2.11-cpan-4ab04211f4c )