Boost your X performance!!

Boost your X performance!!

Post by Thilo J. Mahn » Sat, 26 Aug 1995 04:00:00

Hi folks,

this is a trick to boost your performance under X (or plain
Linux), if you use programs that need a lot of buffers, for
example TeX & Xdvi.

Linux dynamically allocates the size of the buffers, but will
not swap any pages to the swap file to make place for buffers, even
if this memory is not actually used. I am using emacs & TeX and
Xdvi under X, and whenever I start a TeX or Xdvi job, there is a
lot of disk activity, although there is amply space in the memory
pool: three agetty where I never logged in, initializing code from
emacs, X, xsysinfo, xclock etc....

The remedy: I wrote a small program called "Memhog" which does
nothing but allocate 13MB of memory (I have 16MB) and erase it
(important - otherwise the pages are notactually used).
I put it in my fvwm menu and start it once emacs has loaded.
Almost everything gets swapped to the hard disk. Then, when
I use a function, it will be reloaded, BUT ONLY STUFF
THAT YOU USE IS RELOADED. Result: emacs & tex & xdvi will use
the hard disk only to save their files, all the fonts etc.
are in the buffer.

You will be amazed at how much memory you can gain.

Here is a sample program that does the job (I not at my pc, so
I can't test it):
               /--- use a figure less than your main memory size
#define SIZE (13*1024*1024/4)
int a(SIZE);    <-- these should be brackets
void main(void)
(  <- this should be a left brace
   int i;
   for(i=0; i<SIZE; i++)
     a(i)=4711;    <- brackets again
)  <- and a right brace
I have a spelling checker.                  Thilo Mahnig

It plane Lee marks four my review
Miss steaks aye can knot see.      (J.H.Zar)