[Mono-list] Mod-mono-server using too much CPU, running too many
times
Joshua Tauberer
tauberer@for.net
Fri, 01 Oct 2004 17:02:40 -0400
Gonzalo Paniagua Javier wrote:
> That's likely to happen if you use the managed file system watcher, not
> with FAM, for large directories (many files)
FAM was failing on FAMOpen. I read somewhere that portmap has to be
running for FAM to work, which it wasn't. But even after starting
portmap and xinetd it still falls back on the managed watcher.
I made two changes to the managed watcher, and for now Mono is humbly
using 0.0-0.1% cpu while it's idle. Firstly, I set the update delay to
be 50 times the time it took to scan for changes (with a lower and upper
bound). This helped, but even while the site was only chaching about 6
files, every few seconds Mono would spike a few percent in cpu usage.
Then I thought that the scan for changes might be faster if Mono did not
have to iterate through the contents of directories. It has to do this
if there's a wildcard in the mask, but if the mask is just a filename,
as is (always?) the case for caching, checking whether that file exists
directly might be faster. So, I have it always check with File.Exists
for the file, and only if that fails does it use
Directory.GetFileSystemEntries. If there are wildcards, File.Exists
should, I think, always return false, so that's fine, but I haven't
tested it.
My unscientific benchmarks show that using
Directory.GetFileSystemEntries takes ~0.003 seconds per call, for
directories with only a small number of files and with a file mask with
no wildcards. Calling File.Exists only takes ~0.0001 seconds. I'm
skeptical that this is what is actually helping -- they're such small
numbers.
>>2) How does mod_mono work in relation to Apache's prefork module?
>
> That used to happen if you get a few requests when mod_mono has not
> started mod-mono-server for the first time. After the burst only one of
> those mono instances is really used. I'll file a bug report about this
> and fix it.
Also I'm getting a few defunct mono's laying around (which disappear on
an httpd restart).
Thanks for your explanations, Gonzalo!
--
- Joshua Tauberer
http://taubz.for.net
** Nothing Unreal Exists **