UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2007-03-23 05:16 PM

thinking
Member
Registered: 2005-09-15
Posts: 103

Re: caching executables (elf) binaries?

[email protected]

to explain my problem/idea/project/whatever i'll use an analogy.
given is a server running an apache
within the apache a few php script's are running, like a simple webapplication (like a forum)
if the traffic is high you'll begin to use an opcode cache for php
this means, if php request's a source code file the cache recognizes the "request" and searches the file in hash
if the file is found within the cache's shared memory the file is loaded from the memory
if not, it is loaded from the file system (harddisk, nfs, whatever)
which means (in this case) php doesn't need to load/compile the source cause it's preloaded by the cache

currently i developed a relatively simple application cluster
a request for a service is delivered to a host
the request get's currently processed by a php script (see apache, opcode cache, ...) BUT it should/will be possible to process the request by a simple application (i'll use stdin/stdout = tcp socket for the communication tunnel)
now i thought about implementing a cache similar to the above described php cache but for binary executables
currently my first/only idea is using some kind of ramdisk like this
1. create ramdisk
2. copy executables into ramdisk
3. in case of a request, run the applications only from ramdisk

well, any ideas, recommendations?
what are my possiblities?
btw: it is a userland application, so i think a kernel module/hack would be too much effort, but if it's the only meaningful possiblity i'll try

[email protected]

Offline

#2 2007-03-23 06:25 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: caching executables (elf) binaries?

The caching makes sense for php files as those must be compiled. But now you're talking about executables already, so there is not much left to cache. Caching the file in RAM is already done by the kernel, so if your program does it too it's just wasting memory.

So don't cache the file, let the kernel do that. At the most use madvice(2) to give the kernel hints if needed, or if you really want to have it in RAM use mlock(2). To see if doing the above is useful you can call mincore(2) to see if it would've changed anything (call it before executing the file, and after, and see if there's a difference).

Offline

#3 2007-03-24 05:59 PM

biologz
Administrator
From: Puking on the pavement
Registered: 2005-11-02
Posts: 396

Re: caching executables (elf) binaries?

Hi,

I don't wanna say a bullshit but couldn't you use sticky bit instead?


gethostbyintuition() is still a dream of mine

                                                 -- quoted from bash

Offline

#4 2007-03-24 06:32 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,847
Website

Re: caching executables (elf) binaries?

Offline

Board footer

Powered by FluxBB