Page 1 of 1

Lazy-Loading OS

Posted: Tue Feb 17, 2015 11:00 am
by SpyderTL
Had a couple of thoughts this morning about OS design that I thought that I'd share.

We've discussed the idea of avoiding the Windows "problem" of a) taking 30+ seconds to boot, b) taking 5+ minutes to fully perform startup actions and settle down to near 0% CPU usage and c) trying to Pre-cache as much information as possible, in order to "speed things up".

So, I was thinking about what it would look like to take the "polar opposite" approach, and taking that to the extreme. In other words, what does the OS actually NEED to do during startup? Setup the CPU? Setup the OS memory manager? Load the Kernel into memory? Setup the display? Interrupt handlers? Setup PIC?

Traditionally, you would also do things like setting up a process manager, set up multiple CPUs and APICS, initialize network devices and connections, get IP addresses, load drivers, etc.

But how much could you "put off" until it is actually needed? Could you start up in single threaded mode, with no scheduler, and switch to multi-threaded mode and startup the scheduler if more than one process was started? Could you leave all of the inactive CPUs/cores uninitialized until they are needed? Could you initialize them individually, as needed?

Could you leave, say, 80% of your Kernel on disk until it is needed?

What other things could you delay until absolutely necessary? And what would that OS look like to the user? (Probably a lot like MS-DOS... :))

Re: Lazy-Loading OS

Posted: Tue Feb 17, 2015 12:02 pm
by Techel
If you turn on windows' debugging on start you can see the drivers are really taking the most of the time. Other things like intialising harware and cpu should not take as much. So loading drivers on demand is be a good idea.

Re: Lazy-Loading OS

Posted: Tue Feb 17, 2015 12:31 pm
by BrightLight
Roflo wrote:If you turn on windows' debugging on start you can see the drivers are really taking the most of the time. Other things like intialising harware and cpu should not take as much. So loading drivers on demand is be a good idea.
Even if you see what exactly is Windows loading on start-up, it's too much time for little drivers. Linux can load 10 times faster than Windows 8.1 on an Intel Core i3 with 2.40 GHz and 4 GB of RAM (my laptop.)
I just don't get why until now, why is Windows slower than Linux in every aspect?

Re: Lazy-Loading OS

Posted: Tue Feb 17, 2015 12:41 pm
by Techel
omarrx024 wrote:I just don't get why until now, why is Windows slower than Linux in every aspect?
I think the biggest problem with windows is compatibility.

Re: Lazy-Loading OS

Posted: Tue Feb 17, 2015 12:41 pm
by BrightLight
Roflo wrote:I think the biggest problem with windows is compatibility.
Compatibility with what?

Re: Lazy-Loading OS

Posted: Tue Feb 17, 2015 1:28 pm
by SpyderTL
Windows 3.1? I'm pretty sure most applications that ran on Win 3.1 will run on Windows 8.1 32-bit.

That's a lot of baggage to carry around. :)

Re: Lazy-Loading OS

Posted: Tue Feb 17, 2015 4:35 pm
by iansjack
omarrx024 wrote:
Roflo wrote:If you turn on windows' debugging on start you can see the drivers are really taking the most of the time. Other things like intialising harware and cpu should not take as much. So loading drivers on demand is be a good idea.
Even if you see what exactly is Windows loading on start-up, it's too much time for little drivers. Linux can load 10 times faster than Windows 8.1 on an Intel Core i3 with 2.40 GHz and 4 GB of RAM (my laptop.)
I just don't get why until now, why is Windows slower than Linux in every aspect?
That's interesting. I have the opposite experience. Windows 8 and, to a greater extent, Windows 10 load to a useable state faster than Linux does. They then continue to do some obvious background work for a little while. The biggest culprits for delays seem to be indexing and anti-virus scans. My Linux distribution does neither of these tasks. Another time-waster is checking for updates both from Microsoft and from third parties. It is, of course, possible to turn off all of these activities and so reach a more level playing ground compared with Linux.

I think that Windows has recently made significant strides in reducing start-up times and I believe it is now the best of the bunch (achieved partially through what some might regard as trickery - but if it works, it works).

Re: Lazy-Loading OS

Posted: Wed Feb 18, 2015 12:36 am
by Roman
Windows is a full-blown OS. Linux is a kernel. What Linux-based OS are you talking about?

Re: Lazy-Loading OS

Posted: Wed Feb 18, 2015 12:59 am
by iansjack
I don't want to get bogged down in semantics. I mean booting a Linux distribution (in this case Fedora and Gentoo installs with various desktop managers) into a state where you can start to do useful work. So I'm using the word "Linux" in the sense that most people use it, as opposed to "the Linux kernel".

I'm saying that my installation of Windows 10 boots to a useable desktop in less time than any of my installed Linux distributions do. Anecdotal evidence, I realize, as most such accounts are.

Re: Lazy-Loading OS

Posted: Wed Feb 18, 2015 1:27 am
by alexfru
One should take a closer look at the number of processes and threads in their Windows Vista/7. There will be hundreds of threads in the system before one starts the first application after boot. There are a bunch of services and other things that are mostly dormant but contribute to boot time and memory usage because they have to be loaded and they have run until a certain point where they block and start waiting for whatever events they're interested in. My Windows 7 has about 100 services started at the moment and over 100 processes and over 1000 threads. And I have very little software installed and running (the biggest consumer being the web browser with a bunch of pages open in many tabs).

Re: Lazy-Loading OS

Posted: Thu Feb 19, 2015 9:08 am
by embryo
SpyderTL wrote:In other words, what does the OS actually NEED to do during startup?
OS needs nothing, but OS users need much more than nothing. So, your question is about users of your OS. Desktop OSes tend to save user's time because users prefer OSes, that save user's time. So, if you set as your goal to decrease user's waiting time, then there is a plenty of solutions available (and you even have listed some of them in your post). But all solutions boil down to minimization of some selected metric. And the metric selected defines how an OS can behave at some stages of it's life, including the startup stage.

If the metric equals to the time spent by a user while waiting from startup to shutdown, then it is required to get representative statistics of usage patterns and next to extract the metric from the statistics. After it is extracted, you need to determine root causes of the user being waiting. Next you need to sort the findings in descending order and start working on every problem from top down the sorted list of causes. But, of course, you can choose another order of your actions, because of required efforts or personal interest, for example. However, general (and most efficient) approach requires that most important problems (in term of metric influence) were solved first.

Re: Lazy-Loading OS

Posted: Thu Feb 19, 2015 9:21 am
by iansjack
Our System/38 used to take well over an hour to IPL (IBM speak for boot). We're spoilt nowadays!

Re: Lazy-Loading OS

Posted: Wed Feb 25, 2015 12:17 am
by Schol-R-LEA
Conversely, the Canon Cat was designed so that it appeared to boot in less than five seconds - shorter than the warm-up time of the CRT, sometimes - mainly by saving the previous system state at shutdown, including saving a bitmap image of the screen and loading it to the screen immediately the next time it was booted while the rest of the boot process was going on. This was faster than an average user would react to seeing the screen come up, and gave the illusion that the system came up almost instantly.

While it did have a small battery backup memory, it wasn't a true persistent OS - if the system went down unexpectedly (e.g., a power outage), there was no journal to restore, so it would boot a clean system the next time it was started - but for a simple, no frills system it was apparently quite well designed to ensure minimal user headaches.

It is interesting that the person often called 'the father of the Macintosh' (a title he generally repudiated) went so far out of his way to make such a much simpler system, but Raskin apparently saw the post-Lisa form of the Macintosh project as going away from the 'computing appliance' goal he'd originally envisioned. The Cat was actually his original design for the Mac, circa early 1979, before Jobs got ahold of the project and decided to make it a less expensive version of the Lisa. Unfortunately, by 1987 the design was almost ten years old, and showing its age; but that hardly mattered anyway, as Canon got cold feet after only six months and pulled the plug before it really had a chance to get any significant recognition.

Re: Lazy-Loading OS

Posted: Wed Feb 25, 2015 4:40 am
by willedwards
I once cut 10 seconds off of a 30 second smartphone boot time by writing a custom animation library for the swirly boot logo.

When making commercial products there are skilled engineers who analyse boot time and can go as far as reordering function sections in libraries to improve boot.

http://elinux.org/Boot_Time
http://blogs.msdn.com/b/oldnewthing/arc ... 94249.aspx
etc :)