All of lore.kernel.org
 help / color / mirror / Atom feed
From: "M. Koehrer" <mathias_koehrer@domain.hid>
To: eric.noulard@domain.hid, daniel.schnell@domain.hid
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] memcpy performance on Xenomai
Date: Wed, 16 May 2007 08:36:59 +0200 (CEST)	[thread overview]
Message-ID: <16965344.1179297419368.JavaMail.ngmail@domain.hid> (raw)
In-Reply-To: <cbe23c50705151054x779cccb0v2128d3b8ca1bfa87@domain.hid>

Hi!

I am not an memory expert.
However, I think that a zero-only page is handled specially by the MMU
(it actually does not use physical memory).
This is the reason why a malloc for a huge amount of memory is typically successful even if there
is not that much physical memory available.
With malloc and a memset to zero only this will typically not lead to a physical RAM usage (I thinks this
is the "copy-on-write" (COW) stuff)
Thus, I recommend to do a memset with a non-zero value after allocating the memory.

memset(buf1,123,msgsize);  
memset(buf2,123,msgsize);

This should lead to a fair comparison. 

Regards

Mathias
> > Some interesting insights about my last tests.
> >
> > 1.) The culprit is mlockall(MCL_FUTURE|MCL_CURRENT);
> >
> > As soon I leave this away, I get much better results:
> >
> > Without mlockall():
> > Test (10) memcpy of sizes (10485760)
> > 10 memcpy. Time per memcpy: 78147209 [nsec] (134 MB/sec)
> >  finished.
> >
> > With mlockall():
> > Test (10) memcpy of sizes (10485760) ....
> > 10 memcpy. Time per memcpy: 124194618 [nsec] (84 MB/sec)
> >  finished.
> 
> 
> I think you are not measuring the same thing in both case.
> I did some test on 2.6.20 (precompiled debian etch kernel)
> on a 1.6 GHz Pentium M.
> 
> I think the fact that you malloced your buffer and then
> immediatly memcpy the buffers does a non repeatable measure
> (at least on my side)
> depending on something I do not understand .
> 
> Could you try my modified version of your code which
> adds:
> 
> memset(buf1,'\0',msgsize);
> memset(buf2,'\0',msgsize);
> 
> just after malloc (you may try calloc too).
> 
> With this modification
> I get similar figure for the mlockall version on my (quasi)-vanilla kernel.
> 
> that is:
> 
> ./memcpy_perf_mlockall
> Test (10) memcpy of sizes (10485760) ....
> 10 memcpy. Time per memcpy: 35716568 [nsec] (293 MB/sec)
>  finished.
> 
> ./memcpy_perf_memset
> Test (10) memcpy of sizes (10485760) ....
> 10 memcpy. Time per memcpy: 36004454 [nsec] (291 MB/sec)
>  finished.
> 
> ./memcpy_perf
> Test (10) memcpy of sizes (10485760) ....
> 10 memcpy. Time per memcpy: 23881352 [nsec] (439 MB/sec)
>  finished.
> 
> 
> I think that without mlockall or no memset the memory pages you
> requested with malloc and did not --really-- get are brought to
> physical memory only when memcpy comes.
> 
> What puzzles me is WHY it is faster WITHOUT touching the page
> BEFORE memcpy???
> 
> Any memory handling expert is welcomed to answer.
> 
> > Then again I cannot use Xenomai without mlockall()
> > :(
> 
> And you cannot design a realtime application without
> ensuring you really have the memory you requested,
> this is not a xenomai issue (my opinion though).
> 
> PS: on line compilation used:
> 
> gcc memcpy_perf-erk.c -o memcpy_perf -lrt
> gcc -DMLOCK memcpy_perf-erk.c -o memcpy_perf_mlockall -lrt
> gcc -DMEMSET memcpy_perf-erk.c -o memcpy_perf_memset -lrt
> 


-- 
Mathias Koehrer
mathias_koehrer@domain.hid


Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren
ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig
und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer,
nur  39,85 €  inkl. DSL- und ISDN-Grundgebühr!
http://www.arcor.de/rd/emf-dsl-2


  reply	other threads:[~2007-05-16  6:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-15 11:38 [Xenomai-help] memcpy performance on Xenomai Daniel Schnell
2007-05-15 12:16 ` Gilles Chanteperdrix
2007-05-15 14:40   ` Daniel Schnell
2007-05-15 14:50     ` Gilles Chanteperdrix
2007-05-15 15:28       ` Daniel Schnell
2007-05-15 15:41         ` Gilles Chanteperdrix
2007-05-15 17:54         ` Eric Noulard
2007-05-16  6:36           ` M. Koehrer [this message]
2007-05-15 15:18     ` Philippe Gerum
  -- strict thread matches above, loose matches on Subject: below --
2007-05-15 15:59 Fillod Stephane
2007-05-15 16:59 ` Daniel Schnell
2007-05-15 18:03   ` Gilles Chanteperdrix
2007-05-15 20:26     ` Eric Noulard
2007-05-16 20:17       ` Gilles Chanteperdrix
2007-05-16 20:34         ` Eric Noulard

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

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

  git send-email \
    --in-reply-to=16965344.1179297419368.JavaMail.ngmail@domain.hid \
    --to=mathias_koehrer@domain.hid \
    --cc=daniel.schnell@domain.hid \
    --cc=eric.noulard@domain.hid \
    --cc=xenomai@xenomai.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.