You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Bernd Petrovitsch <be...@petrovitsch.priv.at> on 2013/03/07 19:04:22 UTC

Re: fork is vfork?

On Don, 2013-03-07 at 12:14 -0500, David F. Skoll wrote:
> On Thu, 7 Mar 2013 18:56:45 +0200
> Henrik K <he...@hege.li> wrote:
> 
> > You provide no data how you end up with the 4MB etc. And MD is not
> > SA, it might do all sorts of funky stuff.
> 
> I wrote MD, so I'm pretty sure it's not doing any funky stuff.

MD forks the worker process and the worker process initializes libperl
and loads the perl script.

To share more memory on a fork, it should initialize libperl and load
the perl script before forking off the worker processes.


BTW switching to vfork() won't speed up anything significantly IMHO as
processes are (re)started quite seldom - it is not that one starts a
process for each mail .....

	Bernd
-- 
Bernd Petrovitsch                  Email : bernd@petrovitsch.priv.at
                     LUGA : http://www.luga.at


Re: fork is vfork?

Posted by Henrik K <he...@hege.li>.
On Fri, Mar 08, 2013 at 07:09:12PM +0200, Henrik K wrote:
> On Fri, Mar 08, 2013 at 11:55:43AM -0500, David F. Skoll wrote:
> > On Fri, 8 Mar 2013 18:44:54 +0200
> > Henrik K <he...@hege.li> wrote:
> > 
> > > Virgin childs:
> > 79MB private; 2GB shared (~40MB shared/child)
> > 
> > > Used childs:
> > 1.2GB private; 1.2GB shared (~24MB shared/child)
> > 
> > This is roughly what I am seeing with MIMEDefang also: Only 50%
> > shared.  It's better than nothing, but not nearly as good as one might
> > have hoped.  On my system, about 3.5MB of the shared memory is the
> > text portion of libraries such as libperl.so and libc.so which you'd
> > expect to be shared anyway, so really only about 20.5MB/46.5MB of Perl
> > memory is shared for each slave.
> 
> But atleast ~10-20MB of private data per spamd child is the per message scan
> data/blobs etc (can be seen as 20mb heap allocation).  This should not be
> calculated in any memory ratio conclusions.

Also to be noted that these "shared" values are completely vague anyway. 
All that matters is how much real system memory is taken.  As seen by my
previous free reports, master + 50 virgin childs only take total of 137MB. 
At full blast everything take ~1.2GB.

So the real ratio per child might be something like 4MB bogus perl data,
20MB of per-message data.  If the master process takes 50MB memory, this
means the child ratio is _much_ better than 50% (4MB/50MB).  I might dig
deeper into this later with some tools.


Re: fork is vfork?

Posted by Henrik K <he...@hege.li>.
On Fri, Mar 08, 2013 at 11:55:43AM -0500, David F. Skoll wrote:
> On Fri, 8 Mar 2013 18:44:54 +0200
> Henrik K <he...@hege.li> wrote:
> 
> > Virgin childs:
> 79MB private; 2GB shared (~40MB shared/child)
> 
> > Used childs:
> 1.2GB private; 1.2GB shared (~24MB shared/child)
> 
> This is roughly what I am seeing with MIMEDefang also: Only 50%
> shared.  It's better than nothing, but not nearly as good as one might
> have hoped.  On my system, about 3.5MB of the shared memory is the
> text portion of libraries such as libperl.so and libc.so which you'd
> expect to be shared anyway, so really only about 20.5MB/46.5MB of Perl
> memory is shared for each slave.

But atleast ~10-20MB of private data per spamd child is the per message scan
data/blobs etc (can be seen as 20mb heap allocation).  This should not be
calculated in any memory ratio conclusions.


Re: fork is vfork?

Posted by "David F. Skoll" <df...@roaringpenguin.com>.
On Fri, 8 Mar 2013 18:44:54 +0200
Henrik K <he...@hege.li> wrote:

> Virgin childs:
79MB private; 2GB shared (~40MB shared/child)

> Used childs:
1.2GB private; 1.2GB shared (~24MB shared/child)

This is roughly what I am seeing with MIMEDefang also: Only 50%
shared.  It's better than nothing, but not nearly as good as one might
have hoped.  On my system, about 3.5MB of the shared memory is the
text portion of libraries such as libperl.so and libc.so which you'd
expect to be shared anyway, so really only about 20.5MB/46.5MB of Perl
memory is shared for each slave.

Regards,

David.

Re: fork is vfork?

Posted by Henrik K <he...@hege.li>.
On Fri, Mar 08, 2013 at 11:26:39AM -0500, David F. Skoll wrote:
> On Fri, 8 Mar 2013 17:42:58 +0200
> Henrik K <he...@hege.li> wrote:
> 
> > $ pgrep -f 'spamd child' | while read p; do grep Private_ /proc/$p/smaps; done |  awk 'BEGIN {p=0;} $1 ~ /Private_/ {p> += $2;} END {print p;}'
> 
> I would be interested in seeing the output of:
> 
> pgrep -f 'spamd child' | while read p; do grep Shared_ /proc/$p/smaps; done |  awk 'BEGIN {p=0;} $1 ~ /Shared_/ {p> += $2;} END {print p;}'

Here's a new run..

Virgin childs:

$ pgrep -f 'spamd child' | while read p; do grep Private_ /proc/$p/smaps; done |  awk 'BEGIN {p=0;} $1 ~ /Private_/ {p += $2;} END {print p;}'
79364
$ pgrep -f 'spamd child' | while read p; do grep Shared_ /proc/$p/smaps; done |  awk 'BEGIN {p=0;} $1 ~ /Shared_/ {p += $2;} END {print p;}'
2057688

Used childs:

$ pgrep -f 'spamd child' | while read p; do grep Private_ /proc/$p/smaps; done |  awk 'BEGIN {p=0;} $1 ~ /Private_/ {p += $2;} END {print p;}'
1348048
$ pgrep -f 'spamd child' | while read p; do grep Shared_ /proc/$p/smaps; done |  awk 'BEGIN {p=0;} $1 ~ /Shared_/ {p += $2;} END {print p;}'
1271252


Re: fork is vfork?

Posted by "David F. Skoll" <df...@roaringpenguin.com>.
On Fri, 8 Mar 2013 17:42:58 +0200
Henrik K <he...@hege.li> wrote:

> $ pgrep -f 'spamd child' | while read p; do grep Private_ /proc/$p/smaps; done |  awk 'BEGIN {p=0;} $1 ~ /Private_/ {p> += $2;} END {print p;}'

I would be interested in seeing the output of:

pgrep -f 'spamd child' | while read p; do grep Shared_ /proc/$p/smaps; done |  awk 'BEGIN {p=0;} $1 ~ /Shared_/ {p> += $2;} END {print p;}'

Regards,

David.

Re: fork is vfork?

Posted by Henrik K <he...@hege.li>.
On Fri, Mar 08, 2013 at 09:09:27AM -0500, David F. Skoll wrote:
> 
> I think that's what I said originally... but was met with skepticism from
> some.

There is a difference in saying something and actually providing some data. 
I'm sorry but this sounds like "True Believers" (no need to prove anything)
vs "Scepticists" (no matter what you prove, it doesn't matter to them). :-)

Here is my full documentation. I don't really care if you are on sa-users
list and claim to not even have access to spamd, but if we keep going, let's
base the claims on hard data?  If MD behaves differently, that's another
matter and not relevant to SA.


$ uname -a
Linux ubuntu 3.2.0-35-generic #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

$ /usr/local/perl/bin/perl -v
This is perl 5, version 16, subversion 2 (v5.16.2) built for x86_64-linux

$ free
             total       used       free     shared    buffers     cached
Mem:       4049584    3593572     456012          0     290380    1636144
-/+ buffers/cache:    1667048    2382536
Swap:            0          0          0

(even disabled swap so it doesn't interfere)

$ /usr/local/perl/bin/spamd -4 -p 1234 -m 50 --min-children=50 --min-spare=40 --max-conn-per-child=1000 --round-robin -L -d

$ pgrep -f spamd |wc -l
51

$ free
             total       used       free     shared    buffers     cached
Mem:       4049584    3730644     318940          0     290396    1636152
-/+ buffers/cache:    1804096    2245488
Swap:            0          0          0

(memory difference to before spamd running: 137MB)

$ pgrep -f 'spamd child' | while read p; do grep Private_ /proc/$p/smaps; done |  awk 'BEGIN {p=0;} $1 ~ /Private_/ {p += $2;} END {print p;}'
78700

(smaps claims virgin childs are using 78MB / 50 = ~1.5MB/child)

$ find ham.old -type f | while read f; do spamc -p 1234 < $f; done
(zzz..... about 25 messages processed per child)

$ ps axu |grep spamd
hege     23755  0.2  1.0 121608 44244 ?        Ss   17:23   0:01 /usr/local/perl/bin/spamd -4 -p 1234 -m 50 --min-children=50 --min-spare=40 --max-conn-per-child=1000 --round-robin -L -d
hege     23756  2.1  1.2 129400 52400 ?        S    17:23   0:09 spamd child
hege     23757  2.0  1.3 130432 53284 ?        S    17:23   0:09 spamd child
hege     23758  1.0  1.2 127168 50244 ?        S    17:23   0:04 spamd child
hege     23759  0.9  1.2 129636 52628 ?        S    17:23   0:04 spamd child
hege     23760  1.0  1.2 127984 50960 ?        S    17:23   0:04 spamd child
hege     23761  1.2  1.3 130204 53080 ?        S    17:23   0:05 spamd child
hege     23762  1.1  1.2 128312 51324 ?        S    17:23   0:05 spamd child
hege     23763  1.4  1.2 126356 49512 ?        S    17:23   0:06 spamd child
hege     23764  0.9  1.2 128636 51408 ?        S    17:23   0:04 spamd child
hege     23765  1.2  1.2 129112 52056 ?        S    17:23   0:05 spamd child
hege     23766  1.1  1.2 128048 51068 ?        S    17:23   0:05 spamd child
hege     23767  1.0  1.2 127604 50588 ?        S    17:23   0:04 spamd child
hege     23768  1.2  1.2 129244 52376 ?        S    17:23   0:05 spamd child
hege     23769  0.9  1.2 128680 51632 ?        S    17:23   0:04 spamd child
hege     23770  1.8  1.3 133168 56184 ?        S    17:23   0:08 spamd child
hege     23771  0.8  1.2 129112 52096 ?        S    17:23   0:03 spamd child
hege     23772  0.6  1.2 128268 51220 ?        S    17:23   0:03 spamd child
hege     23773  2.4  1.3 132232 55132 ?        S    17:23   0:11 spamd child
hege     23774  1.3  1.2 129260 52288 ?        S    17:23   0:06 spamd child
hege     23775  1.0  1.3 130308 53360 ?        S    17:23   0:04 spamd child
hege     23776  1.8  1.2 126960 49876 ?        S    17:23   0:08 spamd child
hege     23777  1.0  1.2 128608 51692 ?        S    17:23   0:04 spamd child
hege     23778  0.9  1.2 127232 50248 ?        S    17:23   0:04 spamd child
hege     23779  1.5  1.2 128808 51936 ?        S    17:23   0:07 spamd child
hege     23780  1.1  1.3 131680 54504 ?        S    17:23   0:05 spamd child
hege     23781  1.5  1.2 126596 49760 ?        S    17:23   0:07 spamd child
hege     23782  1.0  1.3 130636 53632 ?        S    17:23   0:04 spamd child
hege     23783  1.0  1.3 130816 53716 ?        S    17:23   0:04 spamd child
hege     23784  1.7  1.3 132872 55820 ?        S    17:23   0:08 spamd child
hege     23785  0.8  1.3 131696 54608 ?        S    17:23   0:03 spamd child
hege     23786  2.1  1.3 130104 53208 ?        S    17:23   0:10 spamd child
hege     23787  1.1  1.3 130940 53892 ?        S    17:23   0:05 spamd child
hege     23788  1.0  1.3 130116 52932 ?        S    17:23   0:04 spamd child
hege     23789  1.3  1.3 132556 55388 ?        S    17:23   0:06 spamd child
hege     23790  0.8  1.2 127744 50784 ?        S    17:23   0:04 spamd child
hege     23791  1.1  1.2 125812 48984 ?        S    17:23   0:05 spamd child
hege     23792  1.6  1.3 129812 52804 ?        S    17:23   0:07 spamd child
hege     23793  0.8  1.3 132040 55036 ?        S    17:23   0:04 spamd child
hege     23794  0.6  1.3 129804 52684 ?        S    17:23   0:02 spamd child
hege     23795  0.7  1.2 126640 49556 ?        S    17:23   0:03 spamd child
hege     23796  1.3  1.3 130160 53064 ?        S    17:23   0:06 spamd child
hege     23797  1.1  1.3 131008 53920 ?        S    17:23   0:05 spamd child
hege     23798  1.1  1.3 131016 54120 ?        S    17:23   0:05 spamd child
hege     23799  0.8  1.2 127944 50912 ?        S    17:23   0:03 spamd child
hege     23800  1.3  1.3 132756 55668 ?        S    17:23   0:06 spamd child
hege     23801  1.4  1.2 128584 51584 ?        S    17:23   0:06 spamd child
hege     23802  1.2  1.2 127664 50620 ?        S    17:23   0:05 spamd child
hege     23803  1.0  1.3 131188 54052 ?        S    17:23   0:04 spamd child
hege     23804  1.4  1.3 132212 55240 ?        S    17:23   0:06 spamd child
hege     23805  0.9  1.1 125060 48076 ?        S    17:23   0:04 spamd child

$ free
             total       used       free     shared    buffers     cached
Mem:       4049584    3944384     105200          0     268060     653584
-/+ buffers/cache:    3022740    1026844
Swap:            0          0          0

(memory difference to before spamd running: 1220MB)

$ pgrep -f 'spamd child' | while read p; do grep Private_ /proc/$p/smaps; done |  awk 'BEGIN {p=0;} $1 ~ /Private_/ {p += $2;} END {print p;}'
1350324

(so smaps reports slightly little higher usage, ~27MB per child)

$ pkill -f spamd

$ free
             total       used       free     shared    buffers     cached
Mem:       4049584    2536460    1513124          0     268172     653612
-/+ buffers/cache:    1614676    2434908
Swap:            0          0          0


Re: fork is vfork?

Posted by "David F. Skoll" <df...@roaringpenguin.com>.
On Fri, 08 Mar 2013 13:26:50 +0100
Bernd Petrovitsch <be...@petrovitsch.priv.at> wrote:

> Hmm, I had the impression ages ago with md-2.56 - did this change
> since then?
> [ And I mean with embedded-perl compiled-in and activated. ]

No, I think it's been that way for ages.

> Then I have no idea, why the mimedefang-multiplexor processes have
> next to nothing shared - except that perl actually changes a lot in
> the internal data structures killing any copy-on-write benefits.

I think that's what I said originally... but was met with skepticism from
some.

Regards,

David.

Re: fork is vfork?

Posted by Bernd Petrovitsch <be...@petrovitsch.priv.at>.
On Don, 2013-03-07 at 13:12 -0500, David F. Skoll wrote:
> On Thu, 07 Mar 2013 19:04:22 +0100
> Bernd Petrovitsch <be...@petrovitsch.priv.at> wrote:
> > MD forks the worker process and the worker process initializes libperl
> > and loads the perl script.
> 
> Nope.

Hmm, I had the impression ages ago with md-2.56 - did this change since
then?
[ And I mean with embedded-perl compiled-in and activated. ]

> > To share more memory on a fork, it should initialize libperl and load
> > the perl script before forking off the worker processes.
> 
> That's what it does.

Then I have no idea, why the mimedefang-multiplexor processes have next
to nothing shared - except that perl actually changes a lot in the
internal data structures killing any copy-on-write benefits.
Hmm, perl probably does not separate code from data internally that
much .....

	Bernd
-- 
Bernd Petrovitsch                  Email : bernd@petrovitsch.priv.at
                     LUGA : http://www.luga.at


Re: fork is vfork?

Posted by "David F. Skoll" <df...@roaringpenguin.com>.
On Thu, 07 Mar 2013 19:04:22 +0100
Bernd Petrovitsch <be...@petrovitsch.priv.at> wrote:

> MD forks the worker process and the worker process initializes libperl
> and loads the perl script.

Nope.

> To share more memory on a fork, it should initialize libperl and load
> the perl script before forking off the worker processes.

That's what it does.

Regards,

DAvid.