On Mon, 3 Apr 2000, Paul Barton-Davis wrote:
> >> The following program prints:
> >>
> >> Average msecs per MB 4.914158; Average copy rate: 0.000005 msecs/byte
> >>
> >> if run without root permission (i.e. mlockall() fails), and
> >>
> >> Average msecs per MB 7.417227; Average copy rate: 0.000007 msecs/byte
> >>
> >> if run with root permission.
> >>
> >> Is there a simple explanation ?
> >
> >mlockall() is a privileged call. Performance could improve if all pages
> >are locked. The non-root version doesn't perform as well because
> >mlockall() fails, subjecting the pages to the system's evil memory
> >management schemes (paging/etc).
> >
> >I'm almost positive you know this though, so your question seems strange.
>
> Look at what I wrote again. It runs *slower* when run as root, and
> faster when not. That is, mlockall() causes it run slower.
>
> --p
Not here. If I just comment out your mlockall() it runs at the
same apparent speed one way or the other. FYI, I don't understand
how you are calculating speed, but that's another question altogether.
Script started on Mon Apr 3 13:56:24 2000
[9;0]# cat zzz.c
#include <stdlib.h>
#include <sys/mman.h>
#include <asm/msr.h>
main ()
{
char buf[1048576];
char obuf[1048576];
int i;
float total;
unsigned long now, then;
#define N 1000.0
#define CYCLES_PER_MSEC 450000.0f
total = 0;
#if 0
mlockall (MCL_CURRENT);
#endif
for (i = 0; i < N; i++) {
rdtscl (then);
memcpy (buf, obuf, sizeof (obuf));
rdtscl (now);
total += (float) (now - then);
}
printf ("Average msecs per MB %.6f; "
"Average copy rate: %.6f msecs/byte\n",
total / (N * CYCLES_PER_MSEC),
total / (N * 1048576.0 * CYCLES_PER_MSEC));
}
# gcc -o zzz zzz.c
# ./zzz
Average msecs per MB 5.295031; Average copy rate: 0.000005 msecs/byte
# vi zzz.c
[?1h=[25;1H[K[m[1;1H#include <stdlib.h>[K[1;1H
[K#include <sys/mman.h>
[K#include <asm/msr.h>
[K
[Kmain ()
[K
[K{
[K char buf[1048576];
[K char obuf[1048576];
[K int i;
[K float total;
[K unsigned long now, then;
[K
[K#define N 1000.0
[K#define CYCLES_PER_MSEC 450000.0f
[K
[K total = 0;
[K#if 0
[K mlockall (MCL_CURRENT);
[K#endif
[K
[K for (i = 0; i < N; i++) {
[K rdtscl (then);
[K memcpy (buf, obuf, sizeof (obuf));
[1;1H[25;1H[1;7m "zzz.c" 34 lines, 566 chars [m[K[25;66H [m[1;1H[m[2;1H[25;66H [m[2;1H[m[3;1H[25;66H [m[3;1H[m[4;1H[25;66H [m[4;1H[m[5;1H[25;66H [m[5;1H[m[6;1H[25;66H [m[6;1H[m[7;1H[25;66H [m[7;1H[m[8;8H[25;66H
[m[8;8H[m[9;8H[25;66H [m[9;8H[m[10;8H[25;66H [m[10;8H[m[11;8H[25;66H [m[11;8H[m[12;8H[25;66H [m[12;8H[m[13;1H[25;66H [m[13;1H[m[14;1H[25;66H [m[14;1H[m[15;1H[25;66H [m[15;1H[m[16;1H[25;66H [m[16;1H[m[17;8H[25;66
H [m[17;8H[m[18;1H[25;66H [m[18;1H[m[18;1H[25;66H [m[18;1H[m[18;1H mlockall (MCL_CURRENT);[K[18;1H
[K#endif
[K
[K for (i = 0; i < N; i++) {
[K rdtscl (then);
[K memcpy (buf, obuf, sizeof (obuf));
[K rdtscl (now);
[18;8H[25;66H [m[18;8H[m[19;6H[25;66H [m[19;6H[m[19;6H[25;66H [m[19;6H[m[19;5H[25;66H [m[19;5H[m[19;4H[25;66H [m[19;4H[m[19;3H[25;66H [m[19;3H[m[19;2H[25;66H [m[19;2H[m[19;1H[25;66H [m[19;1H[m[19;1H[25;66H [m[
19;1H[m[19;1H[K[19;1H
[K for (i = 0; i < N; i++) {
[K rdtscl (then);
[K memcpy (buf, obuf, sizeof (obuf));
[K rdtscl (now);
[K total += (float) (now - then);
[19;1H[25;66H [m[19;1H[25;66H [m[19;1H[m[19;1H[25;66H [m[19;1H[25;1H:[Kwq[K
[25;1H[K[?1l># cat zzz.c
#include <stdlib.h>
#include <sys/mman.h>
#include <asm/msr.h>
main ()
{
char buf[1048576];
char obuf[1048576];
int i;
float total;
unsigned long now, then;
#define N 1000.0
#define CYCLES_PER_MSEC 450000.0f
total = 0;
mlockall (MCL_CURRENT);
for (i = 0; i < N; i++) {
rdtscl (then);
memcpy (buf, obuf, sizeof (obuf));
rdtscl (now);
total += (float) (now - then);
}
printf ("Average msecs per MB %.6f; "
"Average copy rate: %.6f msecs/byte\n",
total / (N * CYCLES_PER_MSEC),
total / (N * 1048576.0 * CYCLES_PER_MSEC));
}
# gcc -o zzz zzz.c
# ./zzz
Average msecs per MB 5.295233; Average copy rate: 0.000005 msecs/byte
# exit
exit
Script done on Mon Apr 3 13:57:51 2000
Cheers,
Dick Johnson
Penguin : Linux version 2.3.41 on an i686 machine (800.63 BogoMips).
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Fri Apr 07 2000 - 21:00:10 EST