[personal profile] mjg59
Mir is Canonical's new display server. It fulfils a broadly similar role to Wayland and Android's Surfaceflinger, in that it takes final responsibility for getting pixels onto the screen. XMir is an X server that runs on top of Mir. It permits applications that know how to speak the X protocol but don't know how to speak to Mir (ie, approximately all of them at present) to run in a Mir-based environment.

For Ubuntu 13.10, Canonical are proposing to use Mir by default. This doesn't mean that most applications will be using Mir, though - instead, the default session will run XMir as a full-screen client and a normal X environment will be run on that. This lets Canonical deploy Mir without forcing anyone to update their applications, allowing them to take a gradual approach. By 14.10, Canonical expect the default Unity session to be a Mir client rather than an X client. In theory it will then be possible to run an Ubuntu system without any X applications at all, leaving XMir to do nothing other than run legacy applications.

Of course, this requires a certain amount of replumbing. X would normally be responsible for doing things like setting up the screen and pushing the pixels out to the hardware, but this is now handled by Mir instead. Where a native X server would allocate a framebuffer in video memory and render into it, XMir asks Mir for a window corresponding to the size of the screen and renders into that and then simply asks Mir to display it. This step is actually more interesting than it sounds.

Unless you're willing to throw lots of CPU at them, unaccelerated graphics are slow. Even if you are, you're going to end up consuming more power for the same performance, so XMir would be impractical if it didn't provide access to accelerated hardware graphics functions. It makes use of the existing Xorg accelerated X drivers to do this, which is as simple as telling the drivers to render into the window that XMir requested from Mir rather than into the video framebuffer directly. In other words, when displaying through XMir, you're using exactly the same display driver stack as you would be if you were using Xorg. In theory you'd expect identical performance - in practice there's a 10-20% performance hit right now, but that's being actively worked on. Fullscreen 3D apps will also currently take a hit due to there being no support for skipping compositing, which is being fixed. XMir should certainly be capable of performing around as well as native X, but there's no reason for it to be any faster.

The output drivers aren't the only part of the stack. XMir still needs some way to get input events. You might naively expect that Mir would forward input events to XMir, but the current state of affairs is that XMir loads the existing X input drivers which in turn open the input devices themselves. This explains why XMir currently shows two cursors[1] - the first cursor is the Mir cursor that's being driven by the input events Mir is receiving, while the second is the cursor being drawn by XMir in response to the input events that it's receiving[2].

The final main piece of duplicated functionality is output management. In the case where X is its own display server, it can simply ask the kernel to program the outputs. XMir can't do that, so would have to ask Mir to do it instead. Sadly, that functionality's not implemented yet. Running xrandr on Xmir gives:
Screen 0: minimum 320 x 320, current 1366 x 768, maximum 8192 x 8192
XMIR-1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   XMIR mode of death[3]   60.0*+
which translates as "I have a screen that can be any size from 320x320 to 8192x8192, and have one output of unknown physical size that can only display 1366x768 at 60Hz". Other than the 1366x768, the result will be identical no matter how many outputs you have - XMir currently has no support for configuring multiple displays, and will always report 60Hz. It also has no support for placing monitors into any kind of DPMS state.

Obviously, this is still software under active development. There's three months from now until until Ubuntu is due to release with this functionality enabled by default, and the only significant missing features are xrandr and DPMS support. As long as Mir exposes interfaces for controlling those, they shouldn't be a problem to implement. To most users, the transition from native Xorg to XMir should be completely invisible.

Which is kind of the problem. What benefits does the user gain from using XMir on Mir rather than native Xorg?

Features? XMir is a total of around 1000 lines of code on top of Xorg. It implements no functionality that isn't present in Xorg.

Performance? XMir effectively is Xorg - it's the same code running the same drivers. It's not going to be any faster. At the moment it's actually slower, but that's probably fixable.

Security? Again, XMir is effectively Xorg. It still runs as root. It has the same privileges. There's no security benefit to using XMir instead of Xorg.

Like I said, the transition should be completely invisible - no drawbacks, but no benefits. What it does do is get Mir deployed on a larger number of systems, which means Canonical can both get wider testing of the basic Mir functionality and argue that the number of deployed Mir systems means hardware vendors should support it. Users won't see any of the benefits until Unity transitions to being a native Mir client, which is slated for 14.10 next year.

As a PR move, it's pretty great. The public perception is that Mir has gone from not existing to being sufficient to run a full desktop environment in very little time, and it's natural to compare it to Wayland which has been in development for longer and still isn't running a fully featured desktop session. The problem with that perception is that Mir is doing very little at the moment. It's setting an output mode (by asking the kernel to), allocating a window for XMir to draw into and then pushing that window onto the screen whenever XMir tells it that it's changed. This isn't advanced display server functionality, it's the bare minimum that a display server could possibly do[4]. Which is a shame, because Mir is significantly more functional than that, it's just not being used to do anything we couldn't already do.

In summary: XMir on Mir in Ubuntu provides no user benefits and isn't a compelling technology demo. Mir itself will permit a range of additional features, but isn't slated to be running a user session itself until 14.10. The only obvious benefit to Canonical in shipping XMir on Mir is to gain additional testing, which makes using it in 14.04, a supposedly stable and long term release, a somewhat surprising choice.

[1] Although this is in the process of being fixed
[2] This also explains why, on systems with a trackpoint and a touchpad, only the trackpoint moves the Mir cursor while both move the XMir cursor. The X touchpad driver has put the touchpad in absolute mode, which means it's now reporting events that Mir currently ignores.
[3] "XMIR mode of death" is hardcoded into XMir. I'm really hoping it's a Regular Show reference.
[4] So why hasn't anyone done this with Wayland? Mostly because, as described above, there's no technical benefit in doing so. Wayland does have an X server for compatibility purposes, and if you wanted you could run it as a full screen client and run an entire session underneath it. But you'd gain nothing by doing so. The Wayland X server is intended for running individual clients rather than an entire X session. Run an X client under Wayland and it'll pop up in its own individual window and managed by your Wayland session's window manager, just like it would under X. XMir currently has no support for this "rootless" mode - right now if you want to run X apps under Mir, you'll need to launch an entire X session with its own window manager.

Date: 2013-07-15 09:03 pm (UTC)
From: (Anonymous)
Mir itself will permit a range of additional features, but isn't slated to be running a user session itself until 14.10.

This is scheduled for 14.04 with Unity 8. In fact 13.10 is planned to have an optional Unity 8 preview session included.

Date: 2013-07-16 02:07 pm (UTC)
From: (Anonymous)
That email says that the default option will be Unity 7 on XMir, but doesn't say anything about the presence or absence of a Unity 8 on Mir preview.
From: (Anonymous)
To my mind, the point of releasing Mir in 13.10 is very clear: not *just* the PR of being first-to-market versus Wayland (which like Hurd may now be seen as having the Endless Design syndrome), but more importantly, testing. One of the valid complaints that ubuntu made about wayland was that they preferred a test-driven-development model. Most folks, including me, would take that to mean the same thing as agile programming, i.e. you write the performance-testing-scripts first (which report zero fps at the beginning), and then as you get working code up and running, you already have instant feedback on how well the code works, ability to catch regressions, etc.

However, now I'm starting to think that's not what the ubuntu folks meant by "test-driven" development... they weren't talking about auto-QA regression tests, they were talking about in-the-wild *beta* tests. Ubuntu 14.04 LTS is going to have a full copy of Mir, and a full copy of Unity8, and a full copy of all the rest of the future-Ubuntu-graphics-stack.

They have to support that for five years... but recently, they've started doing *rolling* kernel release on the LTS stuff. Which means, 12.04 LTS came out with kernel 3.2, but later 12.10 came out with kernel 3.5, which was then 'backported' to be the new kernel for 12.04 LTS part deux. Basically, the LTS series will be getting kernel upgrades every six months, shortly after the non-LTS flavor has beta-tested that kernel in the wild.

I fully expect the same approach will apply to 14.04 -- it will get rolling kernel updates, and prolly rolling Mir updates, so that ubuntu need not maintain a "frankenstack". Now, whether rolling kernel upgrades to an LTS distro is a good idea or not remains to be seen -- RHEL/CentOS does not do that (it's their main selling point), although Oracle's downstream RHEL clone *does* seem to be doing the Ubuntu trick of rolling kernel upgrades.

As for graphics stacks, whether Mir's approach to release-early-release-often is able to beat Wayland also remains to be seen. But one thing is for sure: releasing Mir into 13.10 isn't just a PR move, it has real benefits for endusers. Just not the *13.10* endusers -- the downside of releasing Mir into 13.10 is that those endusers will prolly experience bugs and instabilities and whatnot. The upside, for the 14.04 and later endusers, is that Mir will have already gone through a six-month beta, so *their* experiences with Mir will be improved.

p.s. One last note: the crucial difference between Mir and Wayland, which remains to be determined, is how well and how fully they will get support from the proprietary GPU drivers. Not *just* the NVIDIA and AMD binary-blob stuff for the x86 desktops however.

More crucial methinks is the Mali/Tegra/PowerVR/Vivante/OMAP/BroadcomVideoCoreAkaRaspberryPi/etc for the tablet and phone markets, using ARM CPUs. Both the wayland and mir teams -- unfortunately to my mind -- are eagerly pursuing the binary-blob folks, with Wayland aiming more at the ARM stuff (Daniel Stone of the Wayland team has already been involved with a proprietary wayland port to Raspberry Pi), and with Mir seeming to be more interested in the desktop GPU vendors (their homepage explicitly states they are trying to get NVIDIA and AMD onboard with Mir... but also strongly hints they are pursuing ARM vendors, and says outright they want Mir to work with existing binary-blob drivers for Android).

Just when the Mesa9/gallium/radeon/r600/libdrm open-source drivers for the desktop were within striking distance of performance-parity (on 2011-era chipsets at least), too.... As the old fortune cookie curse says: may you live in interesting times.

Profile

Matthew Garrett

About Matthew

Power management, mobile and firmware developer on Linux. Security developer at Aurora. Ex-biologist. [personal profile] mjg59 on Twitter. Content here should not be interpreted as the opinion of my employer. Also on Mastodon.

Page Summary

Expand Cut Tags

No cut tags