On 15. Dec 2023, at 1.59, Alex alex@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.
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.
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.