Understanding computers - a cookery analogy

Other sites and resources for Inkscape users.
User avatar
Xav
Posts: 1209
Joined: Fri May 08, 2009 1:18 am
Location: UK
Contact:

Understanding computers - a cookery analogy

Postby Xav » Tue May 14, 2013 8:46 pm

Over the years I've seen a lot of questions on here - and a lot of confusion - about the inner workings of computers. What's a "core"? What's "hyperthreading"? What is the difference between cache, RAM and the hard drive? Why doesn't Inkscape use the GPU - and what on Earth is a GPU anyway? Why does Inkscape struggle on machines with low amounts of memory?

I've found that one of the best analogies for explaining the workings of a computer is that of a kitchen (for the hardware), and recipes (for the software). They're concepts that everyone is familiar with, and generally map quite well to the bits and pieces that make up a modern computer. Like any analogy, however, it does break down if you stretch it too far, so don't expect to understand the inner workings of a transistor in terms of sugar, flour and chocolate sprinkles.

I hope this will help people without much of a computer background to understand some of the jargon and acronyms - and perhaps help those who already understand this stuff to explain it more easily to others. Additional contributions and explanations are welcome.


Hardware

Consider your computer as a kitchen. It takes raw ingredients and recipes as an input, and produces lovely cakes and pastries as an output. There are a few bits of hardware in and around the kitchen, just as there are different bits of hardware in a computer.

Processor core = Oven.
Cache memory = Work surface.
RAM = Cupboards/fridge in the kitchen.
Hard Drive = Larder, fridge, freezer or cupboard in the utility room.
GPU = Microwave oven.


Let's look at each of these things in turn: the oven is the heart of the kitchen and is used for a range of general purpose cooking. Nearby is some convenient work surface to put things on as you transfer them in and out of the oven, or prepare them for baking - but the work surface is limited in size. The kitchen has cupboards, drawers and a fridge that ingredients and tools are stored in - getting things from a cupboard is a bit slower than getting them from the work surface, but it's still pretty quick, and can hold a lot more. Further afield is a larder, freezer or other storage space which in this case is in a different room. Getting things from there takes a long time compared with getting them from the local cupboards or work surfaces, but there's a huge amount of storage space available. We'll ignore the microwave for now, and come back to it later.

In the computer there is a Central Processing Unit (CPU) which is used for general purpose processing. Directly attached to it is some cache memory that is really quick to access and is used when transferring data in and out of the CPU. There's only a small amount of cache memory available though. A little further away is some Random Access Memory (RAM) which can be accessed pretty quickly, but not as fast as the cache. There's also more space here than in the cache. Much further away (in terms of the time it takes to transfer data, at least) is the hard drive. This is huge compared with the RAM or cache, but takes far, far longer to access.

A processor with more cores is like having multiple ovens - you can cook more things at once, but you're still limited by the shared workspace, cupboards and larder. Hyperthreading is like putting a shelf in the oven, so you can cook two things in a single oven but not quite as efficiently as cooking two things in two separate ovens. So if you have two cores, both with hyperthreading, you can cook four things at once.

Moving things between the work surface and the oven is pretty fast, but you've only got a limited amount of work surface available, so if you want to prepare a banquet you may need to swap things back and forth between the work surface and the cupboards or fridge. Bigger work surfaces means less of that back-and-forth, and similarly a processor with a bigger cache can work on more data before it needs to access the RAM.

32-bit vs 64-bit is kind of like two different sizes of oven. 64-bit just means you can cook bigger dishes, using more ingredients from the cupboard at a time, and letting you benefit from having larger cupboards (more RAM).

If you run out of cupboard space in the kitchen you might need to swap things back and forth to the utility room. That's really slow, as you've got to go through doors, avoid the dog, wander down a corridor, pause at the window to wonder why the neighbour's roses look so much better than yours, and eventually get to the utility room and back. Similarly if you run out of RAM the operating system will try to swap some of its content to the hard drive, but that's really slow in comparison to using data from RAM, which in turn is very slow compared with using it from the cache.

Bringing it all back to Inkscape, this means that big or complex files can be very slow to work with, especially if your machine has insufficient RAM and has to keep swapping to hard drive. Multiple cores, or hyperthreading, can speed things up - but with the 0.48 code it will only speed up rendering of Gaussian Blur filters, I believe. If you're lacking RAM and are swapping to the hard drive, speeding up your blurs will not really have much of an effect; the bottleneck of swapping to disk will be many times higher than the gains from rendering on multiple cores.


Now we'll add one more device to the kitchen: a microwave oven. This is like the processor on a modern graphics card - sometimes referred to as the GPU. There are some things that you can't practically cook in a microwave, but for those things that can it's a lot faster than a conventional oven. Generally you need both a conventional oven, for general purpose cooking, and a microwave for faster but more specialised use. In the same way you have a CPU for general computing, and a GPU for specialised tasks. Graphics cards can also have multiple cores, which is like having multiple microwaves - each one can cook things a lot faster, and you can cook more things in parallel.

This is why there's interest in using the GPU to render things in Inkscape. It will mean much faster processing of filters, and it's a lot easier to upgrade your graphics card than it is to replace your processor (much like it's usually easier to replace the microwave than the oven).


Software

Let's move away from the kitchen now; whilst that's a good analogy for the hardware in your machine, it breaks down quickly when you consider software. For that I've got a related-but-separate analogy: software is like a cake.

When you want a deliciously scrumptious and gooey cake you've generally got two options: buy one or make one. Buying one is easy, but you don't have any control over how its made. Perhaps you'd like fewer nuts or more cherries - sorry, you're out of luck. You just get what the manufacturer supplies. If you make your own, on the other hand, you can change it any way you like. If you're not much of a cook, you can take the recipe to someone who is and get them to bake it for you - perhaps incorporating your changes as well.

That's the difference between Open Source and Proprietary software. The software you use on a computer generally has to be compiled (baked) before it's used. If you buy proprietary software you usually get a pre-compiled application, just like buying a commercial ready-made cake. You can't change the recipe, you just have to accept whatever the baker has created. Open Source software is like having a recipe: you can compile it yourself and make changes to it if you want to - or you can get someone else to compile it on your behalf (such as when you download a pre-built binary for Inkscape). If you want the recipe changed then you can request it (i.e. file a bug), and hope that the master bakers will incorporate your suggestion. Alternatively you can hire your own master baker to make the change for you.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter

User avatar
flamingolady
Posts: 687
Joined: Wed Jun 10, 2009 1:40 pm

Re: Understanding computers - a cookery analogy

Postby flamingolady » Wed May 15, 2013 7:37 am

Thanks, XAV, this is invaluable as a teaching guide for so many of us!

User avatar
lejimi
Posts: 54
Joined: Sat Jun 23, 2012 1:21 am
Location: Bourges (France)

Re: Understanding computers - a cookery analogy

Postby lejimi » Fri May 24, 2013 5:12 am

I like this analogy. It's a bit clearer for me now. Did you invented it ?
Inkscape 0.91 / Ubuntu 12.04
Inkscape 0.91 / Debian Wheezy

Gloire à qui n'ayant pas d'idéal sacro-saint
Se borne à ne pas trop emmerder ses voisins

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Understanding computers - a cookery analogy

Postby druban » Sun May 26, 2013 3:47 am

P
Last edited by druban on Wed May 29, 2013 7:47 pm, edited 1 time in total.
Your mind is what you think it is.

User avatar
lejimi
Posts: 54
Joined: Sat Jun 23, 2012 1:21 am
Location: Bourges (France)

Re: Understanding computers - a cookery analogy

Postby lejimi » Sun May 26, 2013 6:27 am

And the corkscrew ? Where is the corkscrew ?
Inkscape 0.91 / Ubuntu 12.04
Inkscape 0.91 / Debian Wheezy

Gloire à qui n'ayant pas d'idéal sacro-saint
Se borne à ne pas trop emmerder ses voisins


Return to “Inkscape Resources”