Monthly Archives: May 2010

Driver Hell: ATI Radeon and Ubuntu

I recently decided to upgrade my Ubuntu to Lucid Lynx. Previous release worked just fine, so I was very optimistic about the move.

When it booted, I noticed that the fan on my graphics card (ATI Radeon HD 4850) became pretty loud. And louder every minute. After 30 minutes of cursing and googling, I found out that there is an issue in open source drivers. Basically, the GPU is overheating, some even suggested it may get damaged.

Solution 1: If the kernel had KMS (whatever that is), it could work. It will be a part of 2.6.34 kernel, just a minute. Oops, the current kernel in Lucid is 2.6.32. But if you add this boot switch, you will disable some features and it may resolve your problem. The whole idea and explanation is flawed in so many places that I dumped it.

Solution 2: Install drivers from ATI. Get them from their website, start the installer and enjoy. Finally the fan became silent, but also X became very slow with no hardware acceleration. Scan of logs revealed that there is a conflict or unresolved dependency between proprietary and open source drivers.

At this point I became pretty desperate. I wanted to use this system and my time to do something productive, not waste hours on fighting driver issues. That said, I did follow some aggressive solutions. Here’s what finally worked:

  • Reinstall xserver-xorg-core – added or fixed the DRI module that the proprietary driver was missing.
  • That created a conflict that broke down aptitude. Due to an a dependency issue it was impossible to perform an upgrade or use aptitude or dpkg in any other way. I decided to ignore it for the moment.
  • After reboot my graphics driver was unusable again. Apparently I broke something down trying to fix apt.
  • I uninstalled ATI driver using their shell script (apt was still broken).
  • I created a .deb package for Ubuntu/lucid. Installing it, I told it to replace all Ubuntu fglrx packages. That seemed to resolve the conflict apt was complaining about. It seems executable installer did not do it.
  • Graphics driver was still broken and aticonfig was not installed. So I ran the same installer from ATI again (this time directly from the downloaded executable, NOT .deb). It installed aticonfig etc.

Now it seems to work. I did not give up only because I’m a Linux enthusiast unable to work in Windoze. But I am hugely disappointed because not being a complete newbie I wasted hours on this issue. Open source driver is unusable, one dependency was fixed by reinstalling xserver, another by installing proprietary driver twice (once to override open-source packages, then to install what was missing from debs)…

Man, it’s a mess. Stop cheating yourself. There’s no way Linux is going to make it into broad consumer market when even power users are having so many issues. Give up on the shiny fancy features and fix the fundamental flaws first. You wouldn’t buy a car with the best sound system if the engine was broken, would you?

Clojure vs. Java: The Beauty of Conciseness

I decided to take up something completely new: Functional programming in Clojure. It’s far from being the most popular tech on the market, but on the other hand it’s a chance to experience something completely new that might come in handy in future.

One of the first striking observations is how concise it is compared to the old, heavy and static languages. Here’s an excersise: Write a function that flattens a list of objects.

Here’s what it looks like in Java (24 lines, 543 characters):

import static java.util.Arrays.asList;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Hello {
  private static List<Object> myFlatten(Object in) {
    if (in instanceof List<?>) {
      List<Object> out = new ArrayList<Object>();
      for (Object obj : (List<?>) in) {
        out.addAll(myFlatten(obj));
      }
      return out;
    } else {
      return Arrays.asList(in);
    }
  }

  public static void main(String[] args) {
    System.out.println(myFlatten(asList(1, asList(2, 3, asList(3,
      asList(asList(3)))))));
  }
}

Now compare that to Clojure (6 lines, 141 characters):

(defn my-flatten [v] 
  (if(sequential? v)
    (vec (apply concat (map my-flatten v)))
    [v]))

(println (my-flatten [1 [2 3 [3 [[3]]]]]))

In this case Java is awfully verbose. Some of it is related to static typing. That’s fine, we know how useful it becomes as the amount of code grows.

However, even in this trivial example the functional approach and Clojure show their strengths. All the interesting logic resides in this single line:

(apply concat (map my-flatten v))

That has little to do with static typing or richness of Clojure’s standard library. It owes to the functional approach and closures

How simple and readable is that?