On Mon, Jun 13, 2005 at 03:55:31PM -0400, Robert Story wrote:
> On Mon, 13 Jun 2005 13:49:49 +0200 Thomas wrote:
> TA> while doing performance tuning for my net-snmp-based applications I
> TA> noticed that launching external programs (exec/extend/traphandle)
> TA> currently (5.3.dev) involves the brute-force approach
> TA>
> TA> close(1023) = -1 EBADF (Bad file descriptor)
> TA> close(1022) = -1 EBADF (Bad file descriptor)
> TA> ...
> TA> close(3) = -1 EBADF (Bad file descriptor)
> TA>
> TA> (see agent/mibgroup/util_funcs.c::get_exec_{output,pipes}) which looks
> TA> safe but wasteful. This takes ~0.1 seconds in sum on my system (*a lot*
> TA> in terms of real-time processing and scalability, even within the
> TA> limitations of external apps), probably even worse on systems with a
> TA> higher RLIMIT_NOFILE.
> TA>
> TA> Any thoughts on improving this (e.g. by remembering the open fds)? Or is
> TA> there a good reason to keep it the way it is?
>
> The problem is that we don't know what fds custom modules might have opened,
> and we don't want' to pass them to any script. Probably the safest/most
> efficient way of dealing with this would be for the agent to create a small
> pool (maybe even 1) of child processes, which do nothing but wait for a
> command
> to exec. They close the fds when created, so there is no delay when the exec
> is
> needed. After the exec, the child dies, and the agent creates another. This
> also has the performance advantage of getting the fork out of the way earlier
> too.
I think it would be even better to spawn a child that handles spawning of the
executing child processes, the drawback is that the child would have to be a
subagent of some kind, the gain is that we can control all fds in the subagent
and mark them as close-on-exec once the executing child have been started.
If we go down this path I also suppose that this code could be broken out into
a separate binary as it would work well standalon also.
/MF
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders