Nature Oriented Computing

Copyright (C) 2000-2006 Hidetoshi Ohtomo, Nature Heart Laboratory. All rights reserved.

Table of Contents

  1. Introduction and Caveats
  2. Read Them First
  3. Use of Small Software
  4. Software Size Reduction
  5. Make Your Web Pages Light
  6. Hardware Interrupt Reduction
  7. My Linux Days
  8. Credits
  9. Wanted

Introduction and Caveats

I wrote and published this document in the hope of saving the earth from its serious condition, but WITHOUT ANY WARRANTY. It may contain technical errors, which damage the earth in unexpected ways. I cannot be responsible for such circumstances, though I did my best to avoid them.

Read Them First

This document is my original supplement to following works, which explain how to save computer resources while using Unix and X Window System. So please come back after reading them:

Use of Small Software

How much memory does your computer have? These days, software require much more memory than their ancestors did twenty years ago. There was a time when a machine equipped with 256 kilobytes of memory being considered a cutting-edge supercomputer. Since then, software grew larger as they incorporated new ideas and became more user-friendly, and some of them now demand a few megabytes of memory (or even more) each.

There are many software available today, and some of them are light and can be good alternatives for such fat software. Using lighter ones saves natural resources because:

Please pay attention to resource usage of software you use. Commands like ps(1) and size(1) are available for measuring program sizes. Look for and use lighter alternatives. Some of them are even freely redistributable, so it is easy to try them first.

Let me introduce some lighter alternatives.

Operating systems

Linux

Free Unix-like operating system for various architectures including Intel x86, Alpha and PowerPC. Its development is lead by Linus Torvalds. For more information, visit ibiblio.org/pub/Linux/, where many software and documents for Linux gather.

"Run Up-to-date Linux Everywhere" (RULE) Project (www.rule-project.org), lead by Marco Fioretti, works to get Red Hat Linux run on machines with small resources.

NetBSD
Another free Unix-like OS, famous for its wide platform support.
OpenBSD
A free Unix-like OS, spun off from NetBSD for higher security achievements.
FreeBSD
Yet another free Unix-like OS, mainly developed for Intel platform.
Menuet
A GUI OS entirely written in assembly code, being developed by Ville Turjanmaa.

Text editors

vi(1)
Vi is suitable for quick writing, editing, and programming. Vim, which is developed by Bram Moolenaar, is a powerful vi clone. It is available at www.vim.org.
ed(1)
A line editor, which is much smaller than screen editors such as vi. Ed is very shy software, but I love its smallness.
e3
A very small screen editor written by Albrecht Kleine. It has key bindings of Wordstar, emacs, Pico, nedit and vi. Primary version is written in assembly language for x86-based systems, so the size of the binary is around 10 KB, which is smaller than my ed. Experimental version written in C is also available for other systems.
ce
ce, Chet's Emacs, is a small emacs clone developed by Chet Ramey, who is one of the main authors of bash(1).
cat(1)
Cat can be used as a generic editor. From the terminal, it inherits line editing key sequences like "kill-line" (^U) and "word erase" (^W) in addition to backspace (^H). I have heard that Bill Joy used to write software with it, starting with "cat > filename" on his command line. Is this true?

Network clients/servers

lynx(1)
There are many good, informational Web pages, which have no graphics at all. Lynx is for such pages. Combining it with an appropriate image viewer capable of displaying JPEG and PNG formats is sufficient for many cases.
links
"Links is a text-based browser with support for HTML tables and frames." It is developed by Mikulas Patocka.
w3m
w3m is a pager and can be used as a text-based Web browser, too. It is significantly smaller than lynx. It can render tables and frames, and does it very nicely. It is developed by Akinori Ito.
miterm
"Small serial terminal communication program."
Yaku-NS
Small basic DNS, developed by Salvatore Sanfilippo.
betaftpd
Very small single-threaded FTP daemon developed by Steinar H. Gunderson.
balance
"Balance is a simple but powerful generic tcp proxy with round robin load balancing and failover mechanisms." It is developed by Thomas Obermair.

X Window System

Nano-X
Xlib-like API implementation of NanoGUI/Microwindows. It is currently developed by Greg Haerr.
rxvt(1)
A terminal emulator developed by Robert Nation, the creat(2)or of fvwm(1). It is an excellent alternative for xterm(1).
heliwm
Highly Essential Light Itsy-bitsy Window Manager, which I wrote. I used to use fvwm, which is much smaller than twm(1). But I found many features, which were unnecessary for me, so I decided to use smaller one. I found and tried some, but they had either some extra features, which were useless to me, or some aspects which I didn't like. So I wrote my own with "essential" window management features such as moving and resizing, and also with customizable elements such as colors and key bindings.
aewm
aewm is one of the smallest window manager, with basic features. It is developed by Decklin Foster.

If you are looking for a window manager with another extra feature or two, visit www.xwinman.org, a wonderful site for window manager maniacs.

Miscellaneous

diet libc
"A libc that is optimized for small size." It is developed by Felix von Leitner.
asmutils
A replacement for many utility programs in assembly code. Though somewhat limited in features, their sizes are amazingly small. Its development is lead by Konstantin Boldyshev.
date(1)
If you display some sort of clock on your display, think about it: how often do you take a look at it? If you rarely do, quit displaying it and use date instead. Even better solution is to use your wall clock, watch, or grandfather's clock. A sandglass is the best alternative in some situations.
bzip2
A high quality file compressor developed by Julian Seward. It often shows better performance than gzip(1). Learn -9 option, which is common to them.
Your lovely console
If you do nothing more than typing and editing on X, stop using it. X eats up your resource in significant amount. The editors I introduced all run on a console. X generates a "KeyPress event" for each key press, and it is more than 40 bytes in size. It is like using a phone to talk to a person sitting next to you.
twin
"Twin is a text-mode windowing environment: it draws and manages text windows on a text-mode display, like X11 does for graphical windows. It has a built-in window manager and terminal emulator, and can be used as server for remote clients in the same style as X11." It is developed by Massimiliano Ghilardi.

Software Size Reduction

To generate smaller executables with gcc(1), try using "-O[level]" and "-fomit-frame-pointer" options. "-g" option should be avoided unless you are going to debug the program.

"-fomit-frame-pointer" option may not be appropriate for programs which use dynamic shared loading. In such cases, try:

strip -s -R.note -R.comment [ executable_file ]
strip -g -R.note -R.comment [ library_file.{so,a} ]

Please note that libraries stripped with "-R.note -R.comment" options may not function properly in some cases.

Though many programs seem to be small in size, they often are linked to huge libraries. To see which libraries a program is linked with, use ldd(1).

Make Your Web Pages Light

If you author web pages, please pay attention to size of their constituting files. To lessen network traffic jam, you should be responsible for making them as small as possible.

Redundant use of spaces and ineffective use of tags in HTML files should be avoided. Source of this page may be a hint. Also, Dave Raggett wrote HTML Tidy, which corrects HTML-related errors and formats HTML files very nicely. It is freely available at tidy.sourceforge.net.

If you use graphics, ask yourself if you really need them. Yes, "a picture tells a thousand words," but I think it is not always true for the web. Some pages are written using many images, in order to provide links and other decorations. But are they really necessary? A kilobyte of text sometimes tells a lot more than a 16 KB JPEG image.

To reduce load for browsers, it is recommended to use HTML properly according to the specifications. See World Wide Web Consortium's HTML Home Page at www.w3.org/MarkUp/. My personal preference is XHTML 1.0 Strict.

Hardware Interrupt Reduction

Hardware interrupts are what CPU and OS must take care of. The interrupts sometimes become performance bottlenecks, too. By reducing the use of hardware like mouse, keyboard and disks, the number of interrupts can be reduced.

Some software provides keyboard shortcuts for mouse operations. Learn how to use them, since mouse generates much more interrupts then keyboard for most cases.

It is also effective to reduce keyboard typing. For example, many Unix shells provide "alias" feature, which helps shortening long command sentences. Tcsh(1) also has "complete" built-in command, which enhances command line completion very much. If you prefer vi over emacs, don't hesitate to use "bindkey -v". It offers more precise cursor control.

My Linux Days

My notebook computer, whose name is skuld, runs Linux and NetBSD as her operating systems. I configured the Linux kernel with necessary options only, so it reports, "Memory: 30732k/32768k available (500k kernel code, 384k reserved, 1152k data)" upon boot. I compiled some options like "sound" and "isofs" as modules, and use modprobe(1) to load and unload them as necessary, in order to save memory by not running kerneld(8)/kmod(8).

I have stopped using cron daemon, since its only task was to run updatedb(1) every morning, and I rarely use locate(1). Now I run updatedb by hand once in a while.

She is stand-alone, so she probably has forgotten about inetd(8) and other network daemons long time ago. The kernel is advanced power management (APM) enabled, and I disabled update(8) in startup rc. When much disk IO is necessary, I either run sync(8) as often as necessary or invoke update by hand. Since her hard disk is set to go to sleep after two minutes of idle time, these strategies save her battery in significant amount.

She has 32 MB of RAM, and for the most of the time, more than 10 MB are used as cache, and 10 MB or so as buffer. Here is a snapshot at a moment, extracted from /proc/meminfo:

        total:    used:    free:  shared: buffers:  cached:
Mem:  31469568 31047680   421888  4993024  8138752 16519168

This significant use of buffer and cache contributes to the lesser hard disk active time. In addition, when the hard disk becomes active upon a read operation, I try to load all the files, which I expect to use in next 20 minutes or so, into the buffer. So I rarely wake up the disk while it is sleeping. A simple way to do this is "cat [files] > /dev/null".

By the way, skuld has 166 MHz MMX Pentium, 1024x768 LCD, 4 MB of video RAM, and 6 GB of disk space, and exhibits 333.41 BogoMIPS. And yes, I am happy and comfortable in working with her. She is now seven years old.

Aki Helin told me:

Although the CPU uses quite a lot of energy, at least from my experience with laptops it seems that the parts actually using the most electricity are the display, floppy drive, CD-ROM [drive] and hard disk. CD-ROM drives use in general more power than HDD's, so if some data is often needed from a CD, copy it to a HD or take an image and mount it from the HD (using loopback). Display power consumption can be cut down surprisingly much by setting lower contrast and brightness, and using less bright themes in window managers.

...I managed to cut down my laptop's power consumption by more than 30% by putting everything often needed, such as /bin, /lib and $HOME to a ramdisk, so that the HD can fall asleep. This of course requires that you save the actual contents once in a while to the HD, and have enough RAM.

By the way, I have used black for background color for years. For X Window System, "xsetroot -solid black" changes the background to black.

Credits

Following people gave me some of the information in this document:

Wanted

I am looking for more information on light, small, and/or efficient software, which can be good replacement for heavier software. I would also like to hear how you save computer resources. If you have such information, please drop me a line to the address below.

Copyright (C) 2000-2006 Hidetoshi Ohtomo <hok@lab.rim.or.jp>. All rights reserved.
May this planet continue to be earth as long as possible.