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.

Power management policy

(Anonymous) 2011-05-12 04:44 pm (UTC)(link)
The power management policy problem can be seen the other way around: it's a bad design decision that the policy is maintained by a gnome-only program.

Re: Power management policy

(Anonymous) 2011-05-12 04:55 pm (UTC)(link)
Fucking roger that.

What the hell does power policy have to do with a graphical desktop environment? I don't get why what happens when I close my laptop lid should change based on whether or not I am running X.

Seriously?

(Anonymous) 2011-05-12 06:01 pm (UTC)(link)
Look... does everything between Canonical and GNOME (aka Red Hat)...

Have to lead to a long pointless post in the negative tone that accomplishes nothing?

I don't read GNOME planet to ruin my day thank you...

This kind of pointless arguing (with no actually point, if everything is weighed appropriately from a neutral standpoint) is ANNOYING!

Reusing desktop policies

[identity profile] kevinkofler.wordpress.com 2011-05-12 06:39 pm (UTC)(link)
> 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 exact same problem happens with GDM vs. e.g. KDE PowerDevil. The settings are entirely different.

> The only sane solution is to ignore the functionality the
> backend provides and have my greeter run
> gnome-power-manager.

That's a GNOME-only solution and will NOT solve the problem for any other desktop. It also means GDM requires large parts of GNOME which makes it a non-starter for the Fedora KDE spin (which uses KDM instead). LightDM may or may not become a true cross-desktop solution (We'll see what Kubuntu makes of it.), but at least it is designed so that it could technically become one, unlike the entirely GNOME-centric GDM.

> It'll behave differently to your desktop

As I said, it's the same for GDM unless your desktop happens to be GNOME.

> - 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.

That's also what happens with GDM for KDE PowerDevil users, due to you dismissing its additional features as "mak[ing] no sense".

Now, unfortunately, KDM currently does not support power management at all. But running gnome-power-manager is not a cross-desktop solution for that. It does the job for GNOME users, and GNOME users only.


And by the way, another big issue is that GNOME is GDM-centric, e.g. it supports only the GDM interfaces for fast user switching whereas KDE Plasma supports both KDM's and GDM's. (This also implies that supporting GDM's interfaces will be sufficient for LightDM to interoperate with both GNOME and KDE Plasma.)

This "The display manager must match the desktop, ergo all users on the machine must use the same desktop." design needs fixing. The KDE developers do their part to support GDM, why doesn't GNOME support other DMs instead of badmouthing them?

(Anonymous) 2011-05-12 07:25 pm (UTC)(link)
Actually, I'd love to have different power policy from the login screen vs. desktop: If I'm not logged in, I'm not expecting instant access, so I'd rather have shorter timeouts to hibernate, rather than sleep, for example.

perhaps all of thrse functions need not be...

(Anonymous) 2011-05-12 07:48 pm (UTC)(link)
...handled by the dm? It seems as though lennart intends for systemd to handle session management. That seems reasonable to me and given that, there is one less thing for a *dm to worry about. Perhaps the nix tradition(while not always applicable) of one tool for one job should be considered here?
Btw I completely agree with your assessment of "lite" codebases whose very size seems to be their sole grace.

(Anonymous) 2011-05-12 07:59 pm (UTC)(link)
My my, the Gnome Shell vs Unity split is still burning, huh? No worries, though. Most users hate both.

I wish there was a NoDM and no greeters

[identity profile] mapopa.blogspot.com 2011-05-12 08:11 pm (UTC)(link)
Take a look at android it just boots and then
you don't need to log in , it's your netbook and home desktop

One of the first things i do at home and on my netbook is to enable autologin
and most of the time gdm is the pig that stays in memory after it autologins

Finally!

(Anonymous) 2011-05-12 08:13 pm (UTC)(link)
I've been waiting years for a thorough Linux census which would allow one to make these statements.
Do you recall the URL to that extremely thorough census? I've always been curious as to how many desktop users Linux really had!
fluffymormegil: @ (Default)

Re: I wish there was a NoDM and no greeters

[personal profile] fluffymormegil 2011-05-12 08:21 pm (UTC)(link)
My android device takes longer to play the poncy fanfare and swirly graphics at powerup than it takes me to type my login credentials on my netbook or my desktop PC.

Re: Reusing desktop policies

(Anonymous) 2011-05-12 08:38 pm (UTC)(link)
So you say: Consistent behaviour is not possible, therefore GDM is better, because it's behaviour is consistent?
Come on... you can do better.

Re: Reusing desktop policies

[identity profile] kevinkofler.wordpress.com 2011-05-12 09:16 pm (UTC)(link)
Well, GNOME could easily support KDM's fast user switching interface. It has been there unchanged since years before GDM's current one. KDE Plasma does try hard to support GDM's current interfaces despite the continuous catchup games they have to play because GDM keeps changing its interfaces to desktops arbitrarily (because it only cares about GNOME). GNOME shows no interest whatsoever in doing the same for KDM. This sucks.

(FWIW, the only reason shutdown/restart works in GNOME even with KDM is because GNOME now uses ConsoleKit's interfaces to do so, which bypasses the display manager entirely. Of course, this means the policy settings set for KDM in System Settings will get ignored and PolicyKit policies will be used instead. Yet another case of different policies for the same thing. As for GDM, it just dropped its shutdown/restart interfaces, which also required KDE Plasma to play catchup with new incompatible interfaces.)

BSD kernels

(Anonymous) 2011-05-12 09:18 pm (UTC)(link)
The BSD kernel may be more lightweight then linux ( how much of that is missing drivers? ), but it still ships with zfs ;) which is why every storage server I have uses it, whereas my laptop runs kubuntu.

I agree that a yet another login manager will not solve anything, just cause more diversion, which does more to hinder then to help...

Re: Seriously?

(Anonymous) 2011-05-12 09:30 pm (UTC)(link)
Different anon here, but you've gotta be joking? If someone else is devoting their time to pursue a different way of doing things, *they're following the open source spirit*.

They want things to behave differently, so they're putting development effort in to make it work the way they want it to. Good on them!

Any other attitude stinks of monoculture, and doesn't belong in FOSS.

(Anonymous) 2011-05-12 09:36 pm (UTC)(link)
Nothing you've stated makes it the "actively inferior choice", just a *different* choice. As one user stated above, they would actually *prefer* a different set of power management policies when not logged in versus being logged in, so LightDM is a blessing for him/her and anyone else with similar desires.

CADT

(Anonymous) 2011-05-12 09:41 pm (UTC)(link)
Different but similar to a jwz from years ago. If you ever adopt a "No Linux on the desktop" policy you'll know you've become as curmudgeonly :)

[identity profile] vincentt.myopenid.com 2011-05-12 09:45 pm (UTC)(link)
I have no experience with the technical side, but aren't most of the problems you describe inherent to pre-login screens? Shouldn't the login screen have different power management options than a desktop after login? After all, what if different users have different preferences about what should happen when they close the lid? There is no way that the login screen can predict which user is going to log in and adjust its settings on that, so it'll have to use some default/system wide setting. There's _always_ going to be two or more sets of policy, right? I believe this is even true for gdm - its preference come, IIRC, from the special account 'gdm', not from some user that might log in. (That aside, without being able to oversee all possible uses of the display manager, I could on first sight even defend not having a power policy at all, as there is no risk of data loss and the login screen will in most cases only be shown for a short period anyway.)

Re: Seriously?

(Anonymous) 2011-05-12 10:14 pm (UTC)(link)
Just because someone can do something doesn't mean they should. Irrational decisions made under the banner of the spirit of FOSS are still irrational -- people should argue for there choices and decisions and argue for them well. Part of that argument is the levelling of criticism against those arguments by others.

(Anonymous) 2011-05-12 10:29 pm (UTC)(link)
On a multi-user-local-desktop machine, such as in a shared lab, you don't want different user's conflicting policies taking effect at different times. You want a single lab-wide policy dictated by the sysadmins and non-overrideable.

Page 1 of 4