You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by ni...@motortrak.com on 2000/11/24 10:28:34 UTC

Determining memory available for cache

This mail is probably naive. Sorry.

I want to set up a cache, storing html templates and perl widgets (held
in MySQL) that are regularly eval'd. I want to attach timestamps and hit
counts to each stored scalar, to help decide which are the most
important values to cach, and allow updates to the cache if values are
changed. I'm also looking at IPC::Cache.

Now, I only have 128MB RAM. When I'm populating the hash, I can limit
the size of the cache to available RAM by reading freemem from
/proc/meminfo, so I don't run into swap space.

However, when I undef a range of hash values, the free memory in
/proc/meminfo doesn't increase - it seems permanently allocated.

Does anyone have any thoughts on how I can judge whether I have space to
add a value to a cache, or whether I need to clean out unused vales from
the cache.

--Nigel Wetters


Re: Determining memory available for cache

Posted by Glorfindel <le...@akio-solutions.com>.
nigel@motortrak.com wrote:

> This mail is probably naive. Sorry.
>

Not so naive !

>
> I want to set up a cache, storing html templates and perl widgets (held
> in MySQL) that are regularly eval'd. I want to attach timestamps and hit
> counts to each stored scalar, to help decide which are the most
> important values to cach, and allow updates to the cache if values are
> changed. I'm also looking at IPC::Cache.
>
> Now, I only have 128MB RAM. When I'm populating the hash, I can limit
> the size of the cache to available RAM by reading freemem from
> /proc/meminfo, so I don't run into swap space.
>
> However, when I undef a range of hash values, the free memory in
> /proc/meminfo doesn't increase - it seems permanently allocated.
>

As far as I know, kernels are not able to desallocate ( ! ) memory segment,
exept when the allocating process die.

>
> Does anyone have any thoughts on how I can judge whether I have space to
> add a value to a cache, or whether I need to clean out unused vales from
> the cache.
>

You could at server startup store the size of free mem as MEN_FREE of your
system, set the max size of each httpd process at SIZE_PER_MAX_HTTPD ( cf
Apache::SizeLimit ), the maxclient to MAX_CLIENT ( cf your httpd.conf )

Then with the size of CACHED_DATA you should take some decisions.

Hopes it help...



--
Don't be irreplaceable, if you can't be replaced, you can't be promoted.




Re: Determining memory available for cache

Posted by Perrin Harkins <pe...@primenet.com>.
On Fri, 24 Nov 2000 nigel@motortrak.com wrote:
> I want to set up a cache, storing html templates and perl widgets (held
> in MySQL) that are regularly eval'd. I want to attach timestamps and hit
> counts to each stored scalar, to help decide which are the most
> important values to cach, and allow updates to the cache if values are
> changed. I'm also looking at IPC::Cache.

File::Cache is a better choice than IPC::Cache for most things.  In this
case, you can free yourself from worrying about managing memory between
mod_perl and your cache by using File::Cache and letting the OS handle
keeping commonly used pages in RAM.  It wil buffer the frequently used
files and page out unused mod_perl code.  Much simpler.

- Perrin