Matthew Garrett ([personal profile] mjg59) wrote2011-05-12 11:44 am
Entry tags:

LightDM, or: an examination of a misunderstanding of the problem

LightDM's a from-scratch implementation of an X display manager, ie the piece of software that handles remote X connections, starts any local X servers, provides a login screen and kicks off the initial user session. It's split into a nominally desktop-agnostic core (built directly on xcb and glib) and greeters, the idea being that it's straightforward to implement an environment-specific greeter that integrates nicely with your desktop session. It's about 6500 lines of code in the core, 3500 lines of code in the gtk bindings to the core and about 1000 in the sample gtk greeter, for a total of about 11,000 lines of code for a full implementation. This compares to getting on for 60,000 in gdm. Ubuntu plan to switch to LightDM in their next release (11.10).

This is a ridiculous idea.

To a first approximation, when someone says "Lightweight" what they mean is "I don't understand the problems that the alternative solves". People see gtk and think "Gosh, that's kind of big for a toolkit library. I'll write my own". And at some point they have to write a file dialog. And then they need to implement support for handling remote filesystems. And then they need to know whether the system has a functioning network connection or not, and so they end up querying state from Network Manager. And then they suddenly have a library that's getting on for the size of gtk, has about the same level of complexity and has had much less testing because why would you want to use a lightweight toolkit that either does nothing or is 90% of the size of the alternative and crashes all the time.

Adding functionality means that code gets larger. Given two codebases that are of significantly different sizes, the two possible conclusions are either that (a) the smaller one is massively more competently written than the larger one, or (b) the smaller one does less. The gdm authors have never struck me as incompetent, even if some people may disagree with some of their design decisions, and the LightDM authors don't seem to have argued on that basis either. So the obvious conclusion is that LightDM does less.

And, indeed, LightDM does less. Part of this is by design - as the proposal to the Gnome development list shows, one of the key advantages of LightDM is claimed as it not starting a Gnome session. And from that statement alone, we can already see that there's been a massive failure of understanding the complexity of the problem.

Let's go back to the comparisons of code size. LightDM's simple GTK greeter is about 1000 lines of code. gdm's greeter is almost 20,000. Some of this is arbitrary shiny stuff like the slidy effects that occur, but a lot of it is additional functionality. For example, some of it is devoted to handling the interface with AccountsService so gdm can automatically update when users are created or deleted. Some of it is providing UI for accessibility functionality. Some of it is drawing a clock, which I'll admit may be a touch gratuitous.

But if your argument is that your software is better because it's doing less, you should be able to ensure that you can demonstrate that the differences aren't important. And the differences here are important. For example, one of the reasons gdm starts a local gnome session is that it wants gnome-power-manager to be there to handle power policy. Closing the lid of my laptop should suspend the system regardless of whether it's logged in or not. LightDM takes a different approach. Because there's no session, it has to take care of this kind of thing itself. So the backend daemon code speaks to upower directly, and the greeters ask the daemon to implement their policy decisions.

This is pretty obviously miserable. Now you've got two sets of policy - one at the login screen, and one in your session. How do I ensure they're consistent? The only sane solution is to ignore the functionality the backend provides and have my greeter run gnome-power-manager. And now how about accessibility preferences? Again, if I want to have the same selection of policy, I need to run the same code. So you end up with a greeter that's about as complex and large as the gdm one, and unused functionality in the backend. Lighter weight through code duplication. We have always been at war with Eurasia.

The entirety of LightDM's design is based on a false premise - that you can move a large set of common greeter functionality into a daemon and just leave UI presentation up to the greeter code. And if you believe that, then yes, you can absolutely implement a greeter in 1000 lines of code. It'll behave differently to your desktop - the range of policy you can implement will be limited to what the daemon provides, even if your desktop environment has a different range of features. It'll have worse accessibility for much the same reason. And eventually you'll end up with a daemon that's absolutely huge in order to attempt to provide the superset of functionality that each different desktop makes use of.

The only real problem LightDM solves is that it makes it easier to write custom greeters, and if you're really seeking to differentiate your project based on your login screen then maybe your priorities are a little out of line. I'm sure that Ubuntu will release with a beautiful 3D greeter that has a wonderful transition to the desktop. It's just a shame that it won't do any of the useful things that the existing implementations already do.

And if you think that when LightDM finally has the full feature set of gdm, kdm and lxdm it'll still be fewer lines of code and take less memory - I hear the BSD kernel is lighter weight than Linux. Have fun with it.

Thank goodness for LightDM

[identity profile] https://www.google.com/accounts/o8/id?id=AItOawlWl6KTdy32ydutlfh8VDHDtQ0fib-jozg 2011-09-24 01:28 am (UTC)(link)
I run XMonad as my desktop, and am grateful that Ubuntu had the good sense to choose software that does what it's supposed to do, and nothing more. No bloated Gnome services started where they're neither needed, nor wanted. No wasted memory. No kitchen sink.

Thank goodness someone at Canonical understands the Unix philosophy: write tools that do one thing, and do it well.

GDM3 broke everything.

(Anonymous) 2011-11-07 05:44 pm (UTC)(link)
LightDM may not be well integrated to GNOME, but GDM3 is much worse, even in a GNOME environment.
No XDMCP. No theming. Ugly and counter-untuitive interface. No ~/.gdmrc support. When I installed that thing, it broke so much that it ignored my xorg.conf entirely, and didn't detect my keyboard or mouse, so I had to use SSH to kill that thing.

That's why Ubuntu choosed LightDM. ANYTHING is better than GDM3.

Moreover, Ubuntu supports more than GNOME (e.g. XFCE, KDE). In that case, GDM3 sucks even more, while LightDM integration is pretty acceptable with everything around there. It's easier to support one generic desktop neutral login manager.

You prove your own points rather brilliantly

(Anonymous) 2012-03-02 07:47 am (UTC)(link)
The point has been raised and expressed multiple times so I don't need to re-state it. This is just a "me too" to lend weight of numbers. You are wrong. This isn't really a matter of opinion. There are simple numbers and metrics that can be added up to show which of these arguments is more valid.

Requiring gnome in an xdm for the reasons you say is so backwards I'm glad to hear you once were but are no longer on some technical advisory board, as long as it doesn't mean you're just on some other one whos effects I might care more about.

Sorry if that's insulting, but you not only levied an insult of your own, first, unprovoked, in public, but did so while not even being right. You begged for it.

gnome-power-management?

(Anonymous) 2012-06-01 07:52 pm (UTC)(link)
I'm sure lots of valid points are raised here, but making a design decision for the "greeter" based on how to get gnome-power-management running is not exactly modular thinking. This kind of thinking sounds like a recipe for disaster on the long term, and I think we're already there.

A better design

(Anonymous) 2021-04-22 07:26 pm (UTC)(link)
Let's look at how Linux/Unix works on the command line:

Small programs that do one thing and do it really well. All complex functionality achieved by combining with other small programs.

Think about how often you pipe something into grep, for example.

The point with regard to display managers:

A display manager should manage the display and call the session. Power management should be handled by the power management tool of choice as defined in the alternatives file or some place like that.

This way I can have one power management program that's system wide, works with my session choice, and is universally available to all programs. The increasing complexity of programs that try to do it all drives me nuts. No program should be the 'one ring.' That's just evil.

And this need not apply only to display managers, power managers, etc. It could easily apply to a number of things done in the Linux GUI environment.

I came across this article because Gnome, KDE, XFCE, and LXDE, not to mention all the different window managers and display managers, cannot agree on where the SINGLE file setting your screen DPI should be. Really, it should be that easy. I don't care how you make it work within your part of the world, but everyone should reach to the same place to find the monitor DPI. Then it would be easy.

/etc/displays.conf.d/10eDP-1, for example.

Go back to the model of calling on another program to do something other than the primary function of the program and we have a more versatile, easier to use X. Or Weyland. Or whatever comes next.

This is what lightdm has tried to do, make a simpler dm. Where they have missed out is allowing the user to choose alternative programs that someone else has written to expand the functionality in a flexible manner. Maybe an api standard needs to be designed: e.g. all power management tools need to meet this standard, all display managers this one, etc. Note I said api: the hooks that different bits can use to connect. It would certainly simplify, at any rate.

Page 2 of 2