Poettering: systemd for Administrators, Part VIII
Poettering: systemd for Administrators, Part VIII
Posted Apr 21, 2011 20:30 UTC (Thu) by wahern (subscriber, #37304)In reply to: Poettering: systemd for Administrators, Part VIII by alvieboy
Parent article: Poettering: systemd for Administrators, Part VIII
One of my fantasy projects is to write a new shell. The core design idea is to forgo forking. Not because forking is slow per se, but so there can be other optimizations. Instead of forking commands, any time a unique PID is required a slave process from a cached pool will be used to direct signals to the executing process. (Or, perhaps, a kernel extension written for the creation of light-weight PID-only processes.)
With most commands running as coroutines in the same process, you can start adding new features and commands to the shell language not feasible when running a collection of separate processes. Similarly, routines like system() and popen() could be run inside the same process.
The tentative name will be "Project Everything Shell".
It'll compile programs for a simple virtual machine, eventually sporting JIT compilation. Like Java the opcodes will be tailored for shell features, with opcodes for psuedo-forking, etc. In a sense it'll be a tiny Unix-oriented virtual machine.
It won't include interactive features, but because it will be written as a library it will be easy to build an interactive shell. That's a whole 'nother fantasy, though.
I'm not even joking. I'm going to make this happen. Eventually....
Posted Apr 21, 2011 22:11 UTC (Thu)
by HelloWorld (guest, #56129)
[Link] (2 responses)
Posted Apr 22, 2011 0:40 UTC (Fri)
by wahern (subscriber, #37304)
[Link] (1 responses)
The shell mirrors the Unix process model very closely, and few other languages do that. That's what makes it useful. The closest example I can think of is Tcl, but it's no more POSIX-shell compatible than any other language.
Posted Apr 22, 2011 3:21 UTC (Fri)
by HelloWorld (guest, #56129)
[Link]
Posted Apr 21, 2011 22:33 UTC (Thu)
by cmccabe (guest, #60281)
[Link] (10 responses)
What other optimizations were you thinking of?
You can already share memory between processes. You can already pass messages between processes without too much overhead. You can already control one process with another process.
Cramming unrelated stuff into a single process makes the kernel scheduler's job harder (in some cases impossible to do well, like on multicore machines). It gets rid of the safety net that a separate address space gives you. Now a bug in your application can mutate the shell's memory and look like a shell bug. Fun fun!
If anything, we need to be moving in the direction of more parallelization and more isolation between components. UNIX got it right the first time around-- and using hardware we wouldn't put in a toaster oven nowadays.
Posted Apr 22, 2011 0:32 UTC (Fri)
by wahern (subscriber, #37304)
[Link] (8 responses)
The shell's raison d'etre was process and file management. Don't you find it odd that all of sudden people are successfully arguing that the shell sucks at process and file management?
I agree we should be moving in the direction of more process isolation. But projects like systemd are moving in the *opposite* direction. init(1) shouldn't be a complex process, and now at least on Linux it's becoming a behemonth. At some point systemd will sprout a scripting language and history will repeat itself. So if we're going to go crazy, I want to join the party.
My idea wouldn't run all system scripts on a single process. There's no mixing of user privileges so security isn't as much of an issue. Concerns regarding bugs apply equally or more so to systemd. And the behavior of shell commands naturally fit a cooperative concurrency model for which coroutines would be a good fit. Plus, the type of shell I'm talking about could fix the issues with control over long pipelines that current shell designs don't or can't easily fix, such as access to exit status.
Posted Apr 22, 2011 1:35 UTC (Fri)
by cmccabe (guest, #60281)
[Link] (6 responses)
I'm pretty sure stuff like preload(8) has this covered.
> I'd want to add useability features like exposing file locking and PID
Bash already exposes file locking. man flock(1).
PID file management is going to be integrated with systemd, rather than exposed in shell scripts like it is now.
> Plus, the type of shell I'm talking about could fix the issues with
Bash has $PIPESTATUS.
> I agree we should be moving in the direction of more process isolation.
No matter what you think about systemd, you can't deny that it runs daemons in a separate process. And that is a very Good Thing.
Personally, I think systemd will work out well in practice. But I haven't had a chance to try it out yet.
Posted Apr 22, 2011 2:11 UTC (Fri)
by wahern (subscriber, #37304)
[Link] (5 responses)
Everything that systemd replaces is the result of endless experimentation made possible by the flexibility that scripting languages--particularly and especially shell scripting--allows. Systemd will now destroy this process. Systemd won't stop the inevitable hacks that people will implement in the future; it's only cleaned up the past hacks. Future hacks are going to be uglier, more obscure, and more frustrating because they're going to include dreadful workarounds to the rigidity of systemd. That is, unless and until systemd reinvents the wheel regarding scripting support.
Come back to this thread in 10 years, tell me I was wrong, and I'll buy you a beer.
Posted Apr 22, 2011 4:39 UTC (Fri)
by josh (subscriber, #17465)
[Link]
Posted Apr 22, 2011 10:13 UTC (Fri)
by mpr22 (subscriber, #60784)
[Link]
Posted Apr 22, 2011 12:45 UTC (Fri)
by mezcalero (subscriber, #45103)
[Link]
The early boot stuff systemd covers is not done from a single process. It's all neatly separated in individual binaries. Nice, modular, simple and parallelizable. All those binaries are simple C programs with no deps but libc. So it's not monolithic at all.
Posted Apr 22, 2011 17:25 UTC (Fri)
by martinfick (subscriber, #4455)
[Link]
http://c2.com/cgi/wiki?LittleLanguage
And, from that perspective, systemd is something well overdo. Unix has many little languages to make simple things simple, and my impression of systemd is that it makes many more simple things simpler.
I love the power of shells, but I cannot endorse what standard linux startup scripts have become. They have always seemed to me to be a place ripe for the introduction of a little language, and I am shocked that it has taken so long! Now that someone has finally done so, and improved on system isolation and dependency management, without taking away the power of using a shell, I am delighted.
I feel that systemd embodies the unix philosophy way better than some tangled mess of shell scripts do (and way better than other startup systems on other OSes). I hope that Lennart continues to push solutions to fill the linux gaps that he sees, particularly the ones which the oldbeards can no longer see because they are so used to overlooking them. Thank you Lennart!
Posted Apr 28, 2011 15:56 UTC (Thu)
by stevem (subscriber, #1512)
[Link]
Posted Apr 22, 2011 15:58 UTC (Fri)
by vonbrand (subscriber, #4458)
[Link]
All the system calls, and a good load of "system" libary functions, are available (almost) directly in Perl (and I'd guess in other such languages)...
Posted Apr 28, 2011 23:45 UTC (Thu)
by steven.blake (subscriber, #13731)
[Link]
Posted Apr 21, 2011 22:42 UTC (Thu)
by cmccabe (guest, #60281)
[Link]
C.
Posted Apr 27, 2011 12:34 UTC (Wed)
by bluss (guest, #47454)
[Link]
I'm not saying that busybox should include yet more utilities, but the ones it has provide a good basis for a non-forking shell.. for the important parts.
But if you could help, the POSIX compliance of busybox' shell needs some improvement to be perfect.
Poettering: systemd for Administrators, Part VIII
Poettering: systemd for Administrators, Part VIII
Poettering: systemd for Administrators, Part VIII
In that case, I'm not even remotely interested. The traditional Unix Shell model is utterly broken by design, and it's impossible to fix it without incompatible changes.
Poettering: systemd for Administrators, Part VIII
> is to forgo forking. Not because forking is slow per se, but so there can
> be other optimizations.
Poettering: systemd for Administrators, Part VIII
Poettering: systemd for Administrators, Part VIII
> complaining about. For example, exec costs like dynamic linking (static
> linking of /bin binaries never caught on).
> management primitives in a way that makes them as convenient to use as in
> C.
> control over long pipelines that current shell designs don't or can't
> easily fix, such as access to exit status.
> But projects like systemd are moving in the *opposite* direction. init(1)
> shouldn't be a complex process, and now at least on Linux it's becoming a
> behemonth. At some point systemd will sprout a scripting language and
> history will repeat itself. So if we're going to go crazy, I want to join
> the party.
Poettering: systemd for Administrators, Part VIII
Poettering: systemd for Administrators, Part VIII
Tell me one thing you would want to do which (a) would need to be managed by one of the things systemd replaces and (b) would be impossible or ugly with systemd. Here's the man pages.
Poettering: systemd for Administrators, Part VIII
Poettering: systemd for Administrators, Part VIII
Poettering: systemd for Administrators, Part VIII
Poettering: systemd for Administrators, Part VIII
Poettering: systemd for Administrators, Part VIII
Poettering: systemd for Administrators, Part VIII
Poettering: systemd for Administrators, Part VIII
Poettering: systemd for Administrators, Part VIII