5 ms·
It's trivial to write this program in C and it is a waste of memory to load up 50 MB of Python just to accomplish this simple task.
by mborch 12y ago
It's trivial to write this program in C and it is a waste of memory to load up 50 MB of Python just to accomplish this simple task.
- FooBarWidget 12y agoActually, the Python process eats less than 5 MB of RAM. Most other stuff on the system eats more RAM. Writing my_init took much more time than you think, and I do not regret choosing Python. My_init not only handles process reaping, but also environment variable handling and bunch of other stuff. Writing text parsers in C is a huge pain (libc has no regexps that are as easy to use as Python). I do not oppose rewriting it in C, but given limited manpower and the tiny benefits it's not high on my todo list either. If you are worried about resource usage, then I would very much welcome contributions for rewriting it in C.
- mborch 12y agoFair enough, but for the record it's at least 10 MB (try starting up Python and import your list of modules). The environment variable handling and other stuff could perhaps be handled in a separate bash-script (or Python), such that the scope of the actual reaper is sufficiently small (to use a lower-level language).
- kstenerud 12y ago5-10MB is a big nothing, unless you're talking about running hundreds of images that consume 20-30mb each. in which case you would have some custom image structure to minimize everything anyway. But then you'd want to consider the infrastructure development cost vs just buying more iron. There comes a point where you have to take a look at the diminishing returns and say "That's good enough."
- pdw 12y agolibc does have regexps. http://pubs.opengroup.org/onlinepubs/009695399/functions/regcomp.html http://pubs.opengroup.org/onlinepubs/009695399/functions/reg...
- edwintorok 12y agoWhy not use already existing init? runit seems small enough: http://smarden.org/runit/ http://smarden.org/runit/ Or if you want small have a look here for minimal PID 1 "So how should init be done right?" http://ewontfix.com/14/ http://ewontfix.com/14/
- FooBarWidget 12y agoBaseimage-docker does use Runit. my_init calls Runit.
- edwintorok 12y agoWhy not use http://smarden.org/runit/runit-init.8.html http://smarden.org/runit/runit-init.8.html and run my_init from runit?