Two of the cool utilities that I've checked out lately have centered around /proc. /proc is a virtual filesystem mountpoint — the filesystem entities are generated on the fly by the kernel. The filesystem entities provide information about the kernel state and, consequently, the currently running processes. [*]
The utilities are preload and powertop. Both are written in C, though I think that either of them could be written more clearly in Python.
preload
Preload's premise is fascinating. Each shared library that a running process is using via MMIO can be queried via /proc/[pid]/maps, which contains entries of the form:
[vm_start_addr]-[vm_end_addr] [perms] [file_offset] [device_major_id]:[device_minor_id] [inode_num] [file_path]
Preload uses a Markov chain to decide which shared library pages to "pre-load" into the page cache by reading and analyzing these maps over time. Preload's primary goal was to reduce login times by pre-emptively warming up a cold page cache, which it was successful in doing. The catch is that running preload was shown to decrease performance once the cache was warmed up, indicating that it may have just gotten in the way of the native Linux page cache prefetch algorithm. [†]
There are a few other things in /proc that preload uses, like /proc/meminfo, but querying the maps is the meat and potatoes. I was thinking of porting it to Python so that I could understand the structure of the program better, but the fact that the daemon caused a performance decrease over a warm cache turned me off the idea.
References
Footnotes
| [*] | A cool side note — all files in /proc have a file size of 0 except kcore and self. |
| [†] | The page_cache_readahead() function in the Linux kernel. |
A few weeks back I got a brand new X60 tablet... to replace my relatively new X41 tablet. What can I say? I'm a sucker for high resolution screens... Lots of code and documentation needs to be viewed in parallel, and the X60 has a beautiful SXGA+ (1400x1050) configuration on its little 12" display (let's just say it's a good thing I'm near-sighted). [*] I'm planning on giving the X41 tablet to my sister for the start of her college career, since it's fully functional, in good condition, and sells for under $800 on ebay.
The Operating Systems Practicum that I'm taking (CS415, my CS project course) forces us to use Microsoft Visual Studio by having a huge, ugly, Windows API-based codebase. I tried to port the first project to make it POSIX compliant, but I couldn't figure out how to manipulate the stack pointer in gcc assembly — this was necessary to port their user-level threading library implementation. The whole mess was terribly x86 dependent to begin with.
As a result, I need to use Microsoft Visual Studio this semester, and so I decided that I would just squeeze the NTFS partition that Lenovo graciously provided to me, as opposed to obliterating it the first chance that I got. [†] I now dual boot, and many people believe that my leetness level has dropped considerably. To compensate, I did a::
% sudo apt-get install compizconfig-settings-manager
and turned my minimize effect to::
Burn @ 200ms @ (type=Normal|Dialog|ModalDialog|Utility|Unknown)
Which made all my windows go up in flames. Of course, this made me totally leet... for about five minutes, at which point I turned compiz off because I didn't want Xorg using up unnecessary resources. [‡]
Footnotes
| [*] | My one gripe is that it shipped with a single pixel that's stuck bright green — single pixels aren't covered under Lenovo's pixel replacement policy. Argh! |
| [†] | Not-so-graciously charging me the Windows Tax for an OS that I can get for free through MSDNAA. |
| [‡] | More evidence that I'll probably never be a Mac OS user. |
I a no u esed in the hoe o o oa
Translation: I am now fully versed in the home row of dvorak.
It's level 9 on the dvorak7min application. I even type with proper form!
This is all pretty exciting for me since I learned how to type qwerty ad-hoc. I starting using computers long before anybody wanted to teach me how to type properly, so I learned where all the keys were through finger-muscle memory (at 70-80 words per minute). I'm not totally sure what learning how to type properly gains me, but I hope that it'll help me avoid all the problems in the WRULD.
Back in freshman year, not knowing any better, I scanned all of the handouts I received as JPEGs. My Automatic Document Feeder (ADF) got me a bit over-excited, so exploring the crustier portions of my filesystem, I find directories full of things like this:
CHEM211 - Prelim 1 - Practice Problems 01.jpg
CHEM211 - Prelim 1 - Practice Problems 02.jpg
CHEM211 - Prelim 1 - Practice Problems 03.jpg
...
Ad nauseam. Seeing these, I thought to myself: It be awesome if there were a utility that would take all these and bind them together in a PDF.
Meet ImageMagick's "convert" utility. It blows my mind.
convert 'CHEM211 - Prelim 1 - Practice Problems'*.jpg 'CHEM211 - Prelim 1 - Practice Problems.pdf'
Done. The resulting PDFs are pretty big, but convert can also manipulate images in just about every way imaginable — I'm just too lazy to figure out how to downsample right now.
I highly recommend checking it out. In Ubuntu's repositories you can find it using:
sudo apt-get install imagemagick