BannerMisc

To use Windows or Not

You might be thinking that I’m going to suggest that you stop using Windows (from Microsoft) and switch to using Linux — and anyone that knows me knows that I love Linux and promote Linux and yes I would suggest switching — but that is not what this post is about. This is about running Linux using X Windows vs using just the shell and CLI (Command Line Interface).

Recently I’ve been experimenting with ArchLinux and to compare size and speed vs. Ubuntu/Debian for use on cloud servers [the quick answer if you don’t want to read my future post is — Arch is faster and smaller]. I was trying various performance test tools and that got me thinking about the impact of running X Windows and its effect on program execution performance.

Let me preface the rest of this article with the disclaimer that I am not a computer system performance engineer and there is no attempt to make this a peer reviewed academic paper. It is just my observations from using a few different performance tests.

As with any sort of performance numbers (your mileage may vary) you need to understand the specifications of the underlying hardware. Though, since I’m comparing the same tests on the same system with just a single changed variable (sort of), the system hardware shouldn’t matter significantly. I will point out where I feel the hardware configuration does impact the results.

The Computer

My test system is my everyday use laptop running — yep, Linux and yes, I just recently switched to Manjaro ArchLinux (more about that in a future post), though I have 5 multi-boot operating systems on the laptop (and I’ll put that also in another post). My system is a 13″ Lenovo Yoga 730. Here are the specs:

Image for post

Laptop Hardware Specifications

The programs that I used to “test” the system performance were: sysbench and hardinfo. I’m sure that there are plenty of people that might argue with my choice, but I decided to use these two specifically because they were:

  • available from the standard software repository;
  • therefore easy to install;
  • easy to run;
  • easy to uninstall.

As I said I’m am not a professional performance engineer so I didn’t want to spend days or months doing exhaustive tests (just a few hours) and when finished leave program artifacts around on my system that I would likely never use again (this is my day to day computer). So sysbench and hardinfo seemed to meet my criteria.

Since this is Linux, it is actually pretty easy to start up the OS with or without starting X. When Linux boots, one of the most likely boot loaders you will see is GRUB (the GNU GRand Unified Bootloader). When GRUB starts, it displays a menu of available operating systems that it can boot and it gives you a short timeout to select one or it launches the default. [If you don’t see a boot menu try holding the shift key when you boot.] During that menu display you can type the letter ‘e’. This then allows you to edit the “boot command” to change boot parameters. By editing the line for the “linux” kernel and putting the number “3” at the end of the line, the OS will boot up into “runlevel 3” (multi-user / text-only) and NOT start the X Window system and instead just present you will a simple text login prompt. If you don’t do anything at boot up time, linux will start and will start up the X Window system, as normal, through the default start up process (I’m writing another post on the X start-up sequence).

Testing without X and with X

I booted my system, hit ‘e’ and modified the linux boot line (all as described above) and was rewarded with the login prompt:

Image for post

and a blinking cursor.

After logging in, I first ran ‘top’ to see how much memory was being used and also ran ‘ps’ to count the number of processes started — 171MB and 186 respectively. I then ran three different sysbench tests: cpu, memory and threads and then hardinfo. I put the information into a file and rebooted.

Once the system rebooted and the display manager started and gave me a login screen (as normal), I logged in and once again ran ‘top’ and ‘ps’. This time the memory usage was 565MB and 238 processes. While the memory usage doubled even the 565MB of memory used is a drop in the 8GB bucket — so no big deal and the change in the number of processes running is also relatively insignificant. Finally, I re-ran the three sysbench tests and hardinfo and captured the results.

Image for post

The Results

I was honestly astounded with the results. I had expected to see some sort of significant difference once I was NOT running with all of the “expected” X Windows overhead. But to my surprise there was really very little difference.

Image for post

As you might see from the table, other than the differences in Processes and Memory there was basically no impact on the benchmarks between running them on X or without X.

So, Why No Difference

I started pondering why there was little or no impact to the benchmark performance even when using X Windows, a few of reasons:

  1. Lots of memory — running X only used less than 400MB of additional memory — leaving gobs of free memory. Back in the old days, when dinosaurs were still roaming Silicon Valley, memory was expensive and adding 400MB of memory would have been cost prohibitive (my first Unix computer system only had 64K of memory — that is not a typo — 64,000 bytes of memory). But today memory is cheap — really cheap and even 8GB machines are becoming less common. Running these tests on a “memory limited” machine would certainly have resulted in different numbers. The processor would have had to spend time swapping data into and out of memory and couldn’t just focus on running the tests.
  2. Multi core processor — from the specs for my computer you can see that it has 4 processing cores. This means that it can execute 4 different threads at the same time and can switch very fast between 8 threads. So it is likely that one or a couple cores were being used to manage X windows and displays and the other cores (possibly even only one) was used to execute the test. Again had I run the tests on a single core computer, the results would have changed — but no one has a single core computer any more.
  3. Solid State Disk — My Lenovo has a 1TB SSD. This means that disk operations are really fast (I mean really really fast). So even if the system needed to swap (which it did not), it would have been fast and only some impact.
  4. Very efficient X Windows system — Finally, it is a testament to all of the developers the X Windows system that it is as small and lightweight as it is. While there are quite a few more processes running, both the memory usage and processor time was not a significant impact.

The Bottom Line

I thought that if I wanted to run a compute intensive application on my laptop I might want to start it without X to eke out some extra performance, but actually on a system with gobs of memory (4GB or more) and multi-cores (4 or more), there really is no reason. Instead just use the X windows system and all of the benefits. Not to slam Windows (from MS), but you can’t avoid the window system overhead — there is no way to turn it off — it is an intrinsic part of the OS. If you have an old 32-bit 386 computer gathering dust with a few hundred MB of memory and a single core, you might consider booting it up without X. Again Linux is your friend, ArchLinux will run just fine. You could never consider running Windows (and I mean the OS from Microsoft) on this computer — ok maybe you could run WindowsXP — but would you want to.

So it was reassuring that with my relatively modern laptop I can enjoy the benefits of a window system and yet not experience a huge detrimental impact to my compute processing — so enjoy X.