unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 3/2] wqblocked: use per-instance unique timer
Date: Sat, 30 Nov 2024 08:26:32 +0000	[thread overview]
Message-ID: <20241130082632.M683063@dcvr> (raw)
In-Reply-To: <20241129235400.138579-1-e@80x24.org>

It was possible to end up with multiple timers being armed on a
busy system from LeiNoteEvent due to the often rapid nature of
renames.  Since ->flush_send will flush all pending messages for
the WQ, it's only necessary to arm a single timer for a given WQ
socket.  This saves some memory and unnecessary wakeups by using
the handy unique timer mechanism in DS.
---
 lib/PublicInbox/WQBlocked.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/WQBlocked.pm b/lib/PublicInbox/WQBlocked.pm
index b2463898..3e4d67f2 100644
--- a/lib/PublicInbox/WQBlocked.pm
+++ b/lib/PublicInbox/WQBlocked.pm
@@ -30,8 +30,8 @@ sub flush_send {
 				PublicInbox::DS::epwait($wq_s1,
 							EPOLLOUT|EPOLLONESHOT);
 			} elsif ($!{ENOBUFS} || $!{ENOMEM}) {
-				PublicInbox::DS::add_timer(0.1, \&flush_send,
-							$self);
+				PublicInbox::DS::add_uniq_timer($self + 0,
+						0.1, \&flush_send, $self);
 			} else {
 				Carp::croak("sendmsg: $!");
 			}

      parent reply	other threads:[~2024-11-30  8:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-29 23:53 [PATCH 0/2] send_cmd IPC improvements for busy sytems Eric Wong
2024-11-29 23:53 ` [PATCH 1/2] send_cmd: use (practically) infinite retries for writers Eric Wong
2024-11-29 23:54 ` [PATCH 2/2] send_cmd: throttle `sleeping on sendmsg' messages Eric Wong
2024-11-30  8:26 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241130082632.M683063@dcvr \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).