ten thousand small processes

Bakul Shah bakul at bitblocks.com
Wed Jun 25 22:15:45 PDT 2003

> On a typical Pentium in our department, the following program becomes
> three times faster when SPACING is changed from 4096 to 128:
>    #define SPACING 4096
>    char data[8 * SPACING];
>    main()
>    {
>      int i;
>      for (i = 0;i < 10000000;++i) {
>        data[0] = data[SPACING];
>        data[2 * SPACING] = data[3 * SPACING];
>        data[4 * SPACING] = data[5 * SPACING];
>        data[6 * SPACING] = data[7 * SPACING];
>      }
>    }

When SPACING is changed from 4096 to 128, this program runs
ten times faster on a pentium pro.  It runs two times _slower_
on an Athlon XP+.  It runs at about the same speed on a PIII.

All one can say is performance is sensitive to data spacing +
processor architecture and you have to tune your programs for
a given machine.

Instead of complaining about wasting 78 megabytes and arguing
about why various proposed solutions fall short and why your
way is the best, why don't you come up with a patch that
saves space for small programs?  If *you* are not willing to
`casually piss away large fractions of a gigabyte of RAM' it's
up to *you* to solve the problem!  If you expect others to
do this for you, you are going about it the wrong way.

More information about the freebsd-performance mailing list