dcsimg

Improving mod_perl Driven Site's Performance -- Part V: Sharing Memory Page 5

By Stas Bekman (Send Email)
Posted Jan 24, 2001


The server was restarted before each new test.

So here are the results of the five tests that were conducted, sorted by the Diff column:

  1. After the first request:
      Version     Size   Shared     Diff        Test type
      --------------------------------------------------------------------
            1  3321856  2146304  1175552  not preloaded
            2  3321856  2326528   995328  preloaded
            3  3244032  2465792   778240  preloaded & methods+compiled

  2. After the second request (all the subsequent request showed the same results):
      Version     Size   Shared    Diff         Test type
      --------------------------------------------------------------------
            1  3325952  2134016  1191936 not preloaded
            2  3325952  2314240  1011712 preloaded
            3  3248128  2445312   802816 preloaded & methods+compiled

The first version shows the results of the script execution when CGI.pm wasn't preloaded. The second version with module preloaded. The third when it's both preloaded and the methods that are going to be used are precompiled at the server startup.

By looking at the version one of the second table we can conclude that, preloading adds about 20K of shared size. As I have mention at the beginning of this section that's how CGI.pm was implemented--to reduce the load overhead. Which means that preloading CGI is almost hardly change a thing. But if we compare the second and the third versions we will see a very significant difference of 207K (1011712-802816), and I have used only a few methods (the header method loads a few more method transparently for a user). Imagine how much memory I'm going to save if I'm going to precompile all the methods that I'm using in other scripts that use CGI.pm and do a little bit more than the script that I have used in the test.

But even in our very simple case using the same formula, what do we see? (assuming that I have 256MB dedicated for mod_perl)


               RAM - largest_shared_size
  N_of Procs = -------------------------
                        Diff
                268435456 - 2134016
  (ver 1)  N =  ------------------- = 223
                      1191936
                268435456 - 2445312
  (ver 3)  N =  ------------------- = 331
                     802816

If I preload CGI.pm and precompile a few methods that I use in the test script, I can have 50% more child processes than when we don't preload and precompile the methods that I am going to use.

I've heard that the 3.x generation will be less bloated. But it's in a beta state as of this writing.

Increasing Shared Memory With mergemem

mergemem is an experimental utility for linux, which looks very interesting for us mod_perl users: http://www.complang.tuwien.ac.at/ulrich/mergemem/

It looks like it could be run periodically on your server to find and merge duplicate pages. It won't halt your httpds during the merge, this aspect has been taken into consideration already during the design of mergemem: Merging is not performed with one big system call. Instead most operation is in userspace, making a lot of small system calls.

Therefore blocking of the system should not happen. And, if it really should turn out to take too much time you can reduce the priority of the process.

The worst case that can happen is this: mergemem merges two pages and immediately afterwards they will be split. The split costs about the same as the time consumed by merging.



Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.