Josef “Jeff” Sipek

Web 2.1

Anyone who knows me at least a little bit, knows that I like things to be optimal. So, it should come to you as no surprise that I attempted to view Facebook using a console based web-browser called Links.

Unfortunately for me and all those other console users out there, Facebook doesn’t share our enthusiasm for efficient software, and instead wants us all to use their website that’s bloated with javascript. Frankly, I don’t need pop-up menus for every single item on the screen. I don’t need textareas that resize themselves when they gain focus. I just don’t need all this bloat — and neither do you!

Later on, I decided to make a screenshot, so I started an xterm in X, and made this…well, I added the red box to highlight and interesting part.

Facebook

This isn’t just Facebook, it’s almost everything on the web these days. Wordpress that I use for these rants, the “admin” interface is bloated, much less so than Facebook and other sites, but still far too much “crap” that doesn’t need to be there.

I think we have reached a point where we’re no longer strictly in the age of Web 2.0. Web 2.0 was about making websites look nice (nice being relative to the web designs of 1990s). I think it’s already web 2.1. It’s not about making websites look even nicer, it’s about making them oozing with bloated javascript.

Someone else who’s also syndicated on Planet LILUG posted two interesting posts. I am NOT saying this sarcastically. He points out the problems with web development. I don’t think he’s as “cynical” about it as I am, but he does see the problems.

Frankly, I don’t care if a website I’m visiting has “nice” combo boxes, or a “fancy” spinner. I want a website to display the content. I should also add that even HTML 3.2 has combo boxes. Sure, they weren’t all shiny, and the data wasn’t all auto-magically pulled from a SQL database over XMLRPC or somesuch nonsense. Those (HTML 3.2) combo boxes displayed choices. What’s the sole purpose of a combo box you ask? Well, believe it or not, it’s to display choices! If you really dislike the way HTML 3.2 looked, you could easily (and quite safely) try HTML 4.01 with some stylesheets. It loads fast, it looks nice, and it doesn’t eat 10-20% of the cpu when you do something as silly as type a lot of text into a textarea.

Don’t even get me started on FCKeditor and other bloatware like it. At one point, some software started embedding such editors into their code — Wikipedia did, Wordpress did, I’m sure others did as well. I disabled it in my Wordpress - it’s bloated enough as it is, I don’t need an additional 3+ second delay to display a page with a big text area to type text into. Wikipedia (or should I say MediaWiki?) tried to do the same thing. I remember disabling it, or doing something to get the old textarea back. I don’t know what they’ve done since then.

So, if you’re in the website biz, do everyone (including yourself) a favor, and Wikipedia article: keep it simple.

Audacity UI feature

Although I’m filing this under the “rants” category, don’t get fooled. The rant is about UIs in general, with Audacity being the exception.

Here’s what happened…I was going to save the recordings of my radio show to my computer, and I noticed that the first hour recording started about 4 minutes after I took over aether. That meant that I needed to get the previous hour, and cut whatever short portion into a small file and keep it along the 3 1-hour long mp3s.

For audio editing, I tend to use Audacity. It works well, it’s rather intuitive, etc., etc. I did the cut, and I was going to export it as an mp3 (to keep the file format consistent with the other 3 hours of audio, otherwise I’d make it an ogg/vorbis). Audacity let me chose the new file name, the new format, but then when it was about to start the actual encoding, this dialog popped up:

Audacity needs libmp3lame

This is absolutely brilliant! And I mean it; I’m not being sarcastic as I usually am. Normally, one of these scenarios happens…

  • …the application gives you a “I can’t find the encoder” at start (if at all), and disables export to that file format
  • …the application gives you a “I can’t find the encoder” at the start of the encoding process, forcing you to abort the encoding, potentially closing the application, to installed the codec, and redoing whatever you did and trying to re-export
  • …the application gives you a “I can’t find the encoder” at the start of the encoding process, making you look through numerous preferences windows to find the one you care about - if it even exists
  • …the application gives you a “I can’t find the encoder” at the start of the encoding process, making you trying to figure out which environment variable (LD_LIBRARY_PATH, LD_PRELOAD, etc., etc.) will make the linker do the right thing, and make the application find the .so

All are sub-optimal. Asking the user for the path to the .so, while not the newbie-friendliest of things, is really the best thing the application could do. This way, if the .so isn’t installed, the user can install it anywhere - system wide or in one’s $HOME - and then point Audacity to it. If the .so is installed but Audacity couldn’t find it, you can manually point it in the right place.

I use Debian, so installing libmp3lame was a matter of making sure I have the Debian Multimedia source in my sources.list, and then running a quick aptitude install to get it on my disk. If you are using a less privileged distro (or if you don’t have root access to install it system-wide), you’ll have to quite possibly go to the project’s website, and grab a copy there. Audacity’s UI designers haven’t failed you there. A convenient way to go to the website to download the .so is right there.

Overall, seeing this dialog didn’t make me agitated that Audacity wants something I don’t have installed, but instead it made me write this post about something that makes sense, but people fail at doing things like this.

Wordpress sucks, archive.org rocks

This is a follow up post to Wordpress sucks from a week ago.

I decided to try to figure out some more category names, and then it hit me…my site is crawled from time to time by The Wayback Machine. So, I searched, and found a copy from November 2007. Not the latest, but quite new enough to have all the categories I had. A little while later, my blahg is back to its former glory. And there was much rejoicing.

Wordpress sucks

As I mentioned in my previous post, I decided to upgrade my Wordpress install. Every single time I upgraded it, I have no problems whatsoever. So, this time around, I didn’t make a backup of the DB tables. Well, that was quite stupid of me. I copy over the new files (2.6 release tarball), and run the upgrade script. Poop! I lost all the category labels and descriptions. Gah! Absolutely, not fun. I have 40 categories, and now they don’t have any labels. Well, not anymore, I’m trying to figure out which category id was which category (sometimes not as easy as it should be). I got some, I’m not sure about some. If you had links to any categories, they’ll still work. If you had links to any posts, they’ll still work. Things will just look a bit disorganized if you look at the list of categories on the website, or if you look at which categories a post belongs to.

Please send any and all hate mail to the Wordpress developers for breaking an upgrade from one stable release to another.

Memory Leaks

Alright, I think I’ve had just about enough. Why does Amarok eat up 22% of my RAM (1GB) after 4 days of running (and playing music for maybe 18 hours of those 4 days)? Why does Firefox use up 33% of my RAM in 4 days?

Why is it that when I shut down the app, and restart it, the usage is 4–5 times less?

Amarok Firefox 2
before app restart 225 MB 338 MB
after app restart 58 MB 72 MB

The only reason I can think of is application being buggy, or having really crappy defaults.

Buggy Applications

Dear developers, believe it or not, when you allocate memory, you also have to free it when you are done with it. If you don’t, you are committing a crime against humanity known as a “memory leak”. This memory is unusable, and essentially becomes dead weight the process carries around. Since it is not used, the OS may swap it out, and before long, your swap file/partition becomes full of memory that has been leaked.

Contrary to popular belief, freeing memory is really simple.

For you C++ coders (yes, that includes you Amarok folks), you simply use the delete keyword followed by a pointer of what you want to free. For example,

delete some_pointer;

If you are using C, the free function is your friend. Just call it, and make the one argument you give it the pointer to what you want to free. For example,

free(some_pointer);

Now, if you are working on a larger project, there might be wrappers around the memory management (malloc/free, new/delete) functions, but whatever the “free this memory” function is called, USE IT.

I can almost hear all the managed languages fans yell: “Just use a language that does garbage collection, and you won’t have to worry about freeing memory.” Well, you are WRONG!

Garbage collectors maintain graphs of memory allocations, and whenever they notice that some piece of memory is unreachable, they mark it as garbage, and free it. Here’s my favorite example for causing leaks in a garbage collected language:

Suppose that you have implemented a class that works as a stack. You implemented it as a list of elements, and an index into the array to mark the top of the stack. Pushing an element is trivial, you just increment the index, and set the reference in the array to the object you want to store. Popping is really easy, you just decrement the index, and you’re done. Right? WRONG! Decrementing the index changes that one integer variable, but that reference in the array is still valid, and therefore the object is still reachable as far as the garbage collector is concerned. Sure, next time you push into that slot, the previous reference will get broken, and the previous allocation will get freed (assuming that there are no other references). But what if you never push that many elements back onto the stack? What if you experienced some high-load spike? You’ll have a large number of objects incorrectly referenced, tieing up memory, and quite possibly making the entire system slower.

How can you solve this? Pretty simple, just reset the reference to some “null” quantity. In Java, that means using the null literal. For example,

some_reference = null;

In Python, None is the proper keyword to use:

some_reference = None

The lesson is, free the memory you allocated when you are done using it.

Crappy Defaults

Many large applications (Firefox included), have many options you can set that affect its behavior. The default options should cover 95% or more of the users (or at least the greatest majority possible). Why such a high number? Well, suppose you settle for making 90% of your users happy out of the box…that means that 1 in 10 people that try your app will not be happy with the defaults. How many will bother checking if there even are knobs they can turn to make it work the way they want? Not all. Some will just try to install another open source app written by someone else that does pretty much the same thing. So, the default options should make as many people happy as possible.

How does this tie into a third of my RAM being used by Firefox? Simple, I do not know if there are any knobs that would “fix” the problem I am seeing. For all I know, someone decided that it was a great idea to be really aggressive about caching web page content in memory — something that’s fine if you have 16GB RAM, but guess what most people don’t.

Whatever it is (defaults that don’t make sense or memory leaks), Firefox and Amarok have problems that must get addressed. What is one of the reasons people complain about Microsoft Word? It takes up tons of memory. Well, I don’t feel like throwing over 200 MB of RAM at an application that plays MP3s, displays a playlist, and cover art.

And before someone suggests that I use Firefox 3… I realize that it is all super-duper-better-than-ever, but let’s think for a second. When the original Firefox was released, it was hailed as the non-leaky, light-weight Mozilla. Then, things started to get slow again. Firefox 2 was supposed to be the super-fast, non-leaky browser. What happened? What happened to my >300 MB of RAM? Now, Firefox 3 is all the rage…do you see the pattern yet?

I think this brings up a larger issue. It’s no secret that I do some Linux kernel coding from time to time. In the kernel, there are leaks at times, but it seems that the kernel leaks are effectively non-existent compared to applications like Firefox. Don’t believe me? How come you can have a server run for over a year and it responds just as well after the year as it did when you booted it? Imagine running Firefox for a year without restarting it? Can you even imagine that? The Linux kernel doesn’t seem to be the only “non-leaky” (there are leaks, but they are very rare, and probably mostly in the ugliest parts of the kernel — device drivers), Apache performs quite well even after running for a while, PostgreSQL, and the list goes on and on.

Why is it that Firefox and other projects seem to have so many problems? The only thing I can think of is the quality control that goes into checking new code before it’s committed. In the kernel community, a patch may get rewritten a dozen times, submitted to mailing lists for review, get comments from people familiar with the subsystem, but also from other developers (and budding developers trying to understand the existing code). It takes a lot of effort to get a piece of code into the kernel, but in the end, that code is well written, well reviewed, and it should benefit most users. Do the Firefox, et. al., communities do this? I do not know, but somehow, I suspect that it isn’t the case.

No Gas

As I have mentioned to many of you, this was my first week of interning at IBM (this is my second year). Well, on Monday, after I got out of work, I realized I needed to get gas if I wanted to get home. I stopped at the first gas station (just down the road), and there were signs on all the pumps saying “No Gas”. Strange, I thought to myself, and so I drove to the next one (about 100m), and guess what…that one also had “No Gas” signs. Somewhat puzzled, and a bit worried (what if all of Wikipedia article: Westchester was out of gas?!). Lucky me, the 3rd station which was mere 50m further down the road, had gas…$3.64 for a US gallon of regular (compared to about $3.40 at home — yes, I realize, that’s still nothing compared to what the folks in Europe are paying).

Linux is Hell

I think I’ve have just about enough of Linux…it barely works. It’s the same story over and over. You want to do something productive, and then you find out that you can’t for a million different reasons — ranging from “trivially solvable” upgrade some library (of course that’ll mean that half a dozen other libraries will want to get upgraded, and along with them half the system), to more serious - the .doc you got won’t open with OpenOffice because it’s using the latest and greatest MS Office format.

So, with all that said, I decided to reinstall my system….here’s what my desktop looks like now:

Linux is link hell, Inferno is like heaven

I couldn’t be happier.

Edit: This was of course April fools’ joke…I’m still using Linux.

Putting the V in HVF

After a number of days trying to avoid having to implement the Dynamic Address Translation (DAT) related code, I finally came to the conclusion that I had to…and so I did…in one afternoon. Woohoo! It actually wasn’t all that bad. Sure, it’s not complete, I still need a way to invalidate entries in the TLB, but right now, the only user that exists is the nucleus, so I just set up the address space, load up a pointer to the first level of page tables (called Region-Third-Table), and toggle the right bit in the Process Status Word (PSW). The DAT hardware turns on, and happily starts translating the addresses from virtual to physical.

One thing that struck me as somewhat wasteful was the fact that if I have, say 128MB to set up page tables for (each page being 4kB), I need to set up 32768 page table entries (PTEs)! Sure, if they are physically fragmented, then you have no choice, but if they are in a couple of (if not one) contiguous chunk, then what? You still need 32768 entries. Oh, and have I mentioned that each entry is 8 bytes? That means, that 128MB needs 256kB of PTEs. Now, you can’t just have just PTEs, that would make the translation far too inefficient. You have segment tables (with segment table entries — STEs) which point to sections of the page tables. As it turns out, each STE can point to a section of only 256 PTEs. In other words, the 32768 PTEs will require 128 STEs — at 8 bytes each, that’s just a single page…but…

Now, imagine we have 2 GB to set up page tables for, that’s…
…2147483648 bytes
…524288 pages
…524288 pages table entries
…4194304 bytes of page table entries (= 4 MB)
…2048 segment table entries
…16384 bytes of segment table entries (= 16 KB)
…~4MB overhead for 2GB

Still doesn’t sound that bad…but if the hardware allowed some kind of extent-based PTE, or if for example the STE had a flag that said this is the physical address and the begining of a 1MB chunk of memory (256 * 4kB = 1MB). A whole lot of memory could be saved.

The Unthinkable: A Bad PhD Comic

I am very disappointed that Jorge Cham did the following two comics:

2007-09-07

2007-09-07

How dares he call computer science an "obscure and esoteric field". As far as I can see, companies are looking for CS PhDs, effectively begging them to join. Grrr….

Wanted: 1996 Mercury Grand Marquis hubcaps

So, about a week ago, I noticed that one of my hubcaps was missing. I found the fact somewhat disheartening, as it makes the car look older and more beaten up than it really is. Anyway, I had an item on my todo list to if I am somewhere near a junkyard of some sort, I’d pick up a hubcap. Well, today, I get out of work, I go to my car, and I approach it from the other side than I usually do. And what do I see? Well…rather…what don’t I see? Second hubcap gone. This if far too odd…losing one makes some sense…but losing 2, on the same axle? Very very odd…anyway, so if you happen to see two hubcaps hanging out somewhere not doing what they should be (e.g., covering my hubs!) tell them where to go. And don’t take a no for an answer.

Powered by blahgd