Hello Songbo,

On Mon, 2024-04-01 at 13:32 +0200, Songbo Wang wrote:
> Hi,
> 
> I am running an OpenSMTPD server with opensmtpd-filter-dkimsign-0.5p2 on 
> OpenBSD 7.4 (amd64). I noticed recently that the dkimsign program was using a 
> lot of memory:
> 
> $ ps ax -orss,command | grep dkimsign
> 110920 /usr/local/libexec/smtpd/filter-dkimsign -d wsb.onl -s viper1 -k 
> /etc/mai
>   304 grep dkimsign
> 
> I am not a C programmer so maybe I am wrong, but it seems to me that over 100 
> MB is a lot for the simple program.

I'm aware of this, and I've also managed to track the reason down. I
haven't spend the time yet to find a good solution yet.

The problem is that after every line libopensmtpd does an event_del/
event_add dance, which libevent queues up for the next kqueue call
without doing any deduplication. This means that if it receives a lot
of lines to send before returning to the event loop (which happens
when you flush a complete cached file from /tmp as dkimsign does) it
can grow to an unreasonable amount of kqueue events. The second part
of the problem is that this array is never freed/shrunk by libevent.

So it shouldn't grow further, unless you sign even larger mails, but
I agree that it's far from ideal.
> 
> And of course the relevant line in my smtpd.conf is the following:
> 
> filter "dkimsign" proc-exec "filter-dkimsign -d wsb.onl -s viper1 \
>       -k /etc/mail/dkim/private.key" user _dkimsign group _dkimsign
> 
> I am not sure if this memory usage is related to how long the program is 
> being ran (server’s uptime is over 100 days), so I didn’t restart the 
> dkimsign program to investigate. But I will be happy to provide more 
> information if needed.
> 
> Thanks,
> --
> Songbo Wang
> 
martijn@

Reply via email to