From f977826a17f8735e6947dd2da380df8c6d0b38d8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 24 Jun 2020 18:45:07 +0000 Subject: lock: reduce inotify wakeups We can reduce the amount of platform-specific code by always relying on IN_MODIFY/NOTE_WRITE notifications from lock release. This reduces the number of times our read-only daemons will need to wake up when -watch sees no-op message changes (e.g. replied, seen, recent flag changes). --- lib/PublicInbox/KQNotify.pm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lib/PublicInbox/KQNotify.pm') diff --git a/lib/PublicInbox/KQNotify.pm b/lib/PublicInbox/KQNotify.pm index 1b5c578e..110594cc 100644 --- a/lib/PublicInbox/KQNotify.pm +++ b/lib/PublicInbox/KQNotify.pm @@ -8,10 +8,6 @@ use strict; use IO::KQueue; use PublicInbox::DSKQXS; # wraps IO::KQueue for fork-safe DESTROY -# only true as far as public-inbox is concerned with .lock files: -sub IN_CLOSE () { NOTE_WRITE } -#sub IN_CLOSE () { 0x200 } # NOTE_CLOSE_WRITE (FreeBSD 11+ only) - sub new { my ($class) = @_; bless { dskq => PublicInbox::DSKQXS->new, watch => {} }, $class; @@ -26,7 +22,7 @@ sub watch { EV_ADD | EV_CLEAR, # flags $mask, # fflags 0, 0); # data, udata - if ($mask == IN_CLOSE) { + if ($mask == NOTE_WRITE) { $self->{watch}->{$ident} = [ $fh, $cb ]; } else { die "TODO Not implemented: $mask"; @@ -52,7 +48,7 @@ sub poll { for my $kev (@kevents) { my $ident = $kev->[KQ_IDENT]; my $mask = $kev->[KQ_FFLAGS]; - if (($mask & IN_CLOSE) == IN_CLOSE) { + if (($mask & NOTE_WRITE) == NOTE_WRITE) { eval { $self->{watch}->{$ident}->[1]->() }; } } -- cgit v1.2.3-24-ge0c7