On Fri, Dec 15, 2023 at 11:37:10AM +0200, Timo Sirainen wrote:
> On 15. Dec 2023, at 1.59, Alex <a...@merlinux.eu> wrote:
> > 
> >>> I would actually like to disable this delay completely on our server 
> >>> setup [6],
> >>> as for chat it is common to receive multiple
> >>> messages in a short period of time,
> >>> e.g. when sending a message to a group and receiving multiple read 
> >>> receipts
> >>> from currently active users.
> >> 
> >> We could of course make this a setting, but maybe it's not necessary. 
> >> Would this behavior also work for you? :
> >> 
> >> * If the current IDLE hasn't notified anything yet, send the notification 
> >> immediately without waiting
> >> * Otherwise, send it max once per 0.5 seconds.
> > 
> > For IDLE this would work and be indistinguishable from no delay
> > as Delta Chat core always interrupts IDLE
> > with DONE as soon as it receives a response (e.g. EXISTS or RECENT, but not 
> > keepalive).
> > 
> > But as this delay code is a part of the storage 
> > (src/lib-storage/mailbox-watch.c)
> > and knows nothing about IDLE, I am not sure how this could be implemented.
> > There is also a plan to implement NOTIFY (RFC 5465) extension support in 
> > Delta Chat [1]
> > where "NOTIFY SET" is executed only once and then there are incoming 
> > notifications
> > for the rest of the IMAP session. NOTIFY uses the same callback and has the 
> > same 0.5 second delay as a result.
> 
> Yeah, it would need some additional API changes to make it work that way.

Maybe move this debounce out of storage and into IDLE implementation 
(imap/cmd-idle.c) then?
Then other callers of mailbox_notify_changes will have no delay.
I only see other calls to mailbox_notify_changes() in imap/imap-notify.c and 
plugins/virtual/virtual-storage.c.
Virtual storage does not need debounce then just as the normal storage.

Then if IDLE implementation manages this debounce itself and sends the first 
notification immediately after each IDLE resetup,
that would be perfect without the need for a configuration option.

As for NOTIFY, same logic cannot be implemented, but hopefully NOTIFY users are 
advanced enough to debounce themselves?
My plan for using NOTIFY is to subscribe directly to receive message body,
so in my case every notification should be immediate.

> 
> > What could work is a change to callback immediately if there have been no 
> > callback call
> > in the last 0.5 seconds and otherwise delay it. Then there will be no 
> > difference as long as two emails in a row
> > do not come wihin half a second.
> 
> I thought it would be important in those cases also? But if not, that's the 
> simplest fix, yes. And it could be shrunk even further from 0.5 seconds to 
> maybe 0.1 seconds.

Yes, ideally first notification after IDLE should always be immediate.
If debounce logic is moved to IDLE implementation this looks simple too.

> > But I also wonder why not remove the delay completely then if there is no 
> > need for it?
> > Debounce can always be implemented on the client side if necessary,
> > if the client does not want to react to interruptions more frequently than 
> > once every half a second
> > it can delay the reaction locally.
> 
> There could be some performance loss if there is never any delay. For example 
> some offline client could connect and start issuing a bunch of flag updates, 
> while another IDLEing connection keeps trying to rapidly send notifications 
> about each of those changes separately instead of bundling them all into a 
> single mailbox sync.

So this IDLE connection is some UI client that will be slowed down by trying to 
refresh the view on every change?
Either the client tries to update the state and redraw the view on every 
incoming update
or it updates the state immediately and debounces view redraws on its own.
In the first case delaying IDLE/NOTIFY updates would not help as the number of 
redraws is not reduced.
In the second case there is no need to debounce on the server side as state 
updates are going to be fast anyway.
_______________________________________________
dovecot mailing list -- dovecot@dovecot.org
To unsubscribe send an email to dovecot-le...@dovecot.org

Reply via email to