Archive for May, 2008

Current Problems With Ubuntu Hardy

Monday, May 26th, 2008

Now that I’ve had a chance to play around with Hardy, I’d thought I’d update my list of problems with it.

  • TERRIBLE default fonts. Open /etc/fonts/conf.d/30-metric-aliases.conf and replace all occurrences of “Nimbus Sans L” and “Liberation Sans” with “DejaVu Sans” to fix them.
  • Very slow and sluggish performance. Any SQL statements that perform a sequential scan, bring out the worst in it.
  • Firefox Flash plugin crashes, and sometimes crashes Firefox. I’m not sure if this is because I’m on x86_64.
  • Firefox extremely slow at times.
  • Power Management extremely buggy.

Forcing VSYNC In ioquake3 (Mac OS X)

Sunday, May 18th, 2008

I’ve been really frustrated with ioquake3 on OS X, mainly because there’s no vsync, and there’s no option to enable vsync that works (I tried setting r_swapInterval to 1, but to no avail), so I had to take things into my own hands. The proper SDL way of doing this, seems to be broken, or maybe the way ioquake3 handles it is broken. In any case, here a patch that should apply to the latest SVN.

ioquake3 vsync patch

Ubuntu Hardy Disappointing

Friday, May 16th, 2008

I’ve been very disappointed with Ubuntu Hardy. By far, the most noticeable thing after installing it is how much slower it is. If you have a beefier system, you probably don’t notice it, but it’s very noticeably slower on my current system. After using it for a while, it really slowed down, and I noticed that the scrollkeeper process was sucking 80% of my CPU. I just killed that process and removed it from /etc/cron.*, so it wouldn’t be spawned again.

I decided to pull up PostgreSQL to run a quick benchmark. I created a very simple table and added 10,000 rows to it, to see how fast SELECT COUNT(*) performed. The results were shocking:


CREATE TABLE test (id INTEGER PRIMARY KEY);
INSERT INTO test VALUES (generate_series(1,10000));

EXPLAIN ANALYZE SELECT COUNT(*) FROM test;
                                        QUERY PLAN
--------------------------------------------------------------------------------------------------
 Aggregate  (cost=170.00..170.01...) (actual time=63.064..63.067...)
   Seq Scan on test  (...145.00...) (actual time=0.034..27.452...)
 Total runtime: 83.567 ms
(3 rows)

WTF!!??!? 83ms!?! On Feisty, the exact same thing takes 8ms, 10x faster than on Hardy! Something is seriously screwed up!

The first thing about Firefox 3b5 I noticed, is it sucks up way more CPU. Just scrolling down the page on some sites causes it to use 90% of my CPU, even with Smooth Scroll turned off. Just sitting idle it uses 1-3% CPU, which isn’t too bad, but FF 2 uses 0% sitting idle. The new UI is nice, though, and it seems “snappier” at times. Also, installing Flash works off the bat, which is really nice (before, I had to download the 32bit version of FF, and use it instead of the one that comes with Ubuntu).

One of the most irritating things about Hardy, is that Power Management is almost completely broken on my system. I set my display to go to sleep after 15 minutes… Three hours later, and it still isn’t sleeping. Now I have to turn my monitor off manually? Barbaric!!!

I don’t have any other criticisms for now. Everything else worked right away, and installing the proprietary NVIDIA driver was a breeze. Bluetooth support is enabled by default, and the usual GNOME improvements are nice… I’m sure I’ll find more to complain about later.

Update: after installing updates, Power Management is now working, and the entire system seems faster.

Update: Power Management is broken again… It works on and off.

Python: Tips For Writing Daemons

Saturday, May 3rd, 2008

Here’s some useful information for writing daemons in Python.

One common problem that people run into is os.fork() producing zombie processes when children quit. This can easily be overcome by setting the SIGCHLD signal to SIG_IGN. ie:

import signal

signal.signal(signal.SIGCHLD, signal.SIG_IGN)

On some flavors of Unix, you are forced to do a double-fork on startup, in order to go into daemon mode. This is because single forking isn’t guaranteed to detach from the controlling terminal. The solution is this:

import os, sys, time

# Main loop
def main():
    # Drop privs.
    os.setgid(1000) # Replace with desired GID
    os.setuid(1000) # Replace with desired UID

    time.sleep(10)
    sys.exit(0)

if (not os.fork()):
    os.setsid() # Become session leader
    pid = os.fork()

    if (pid):
        # Parent, write PID file
        fp = open('/var/run/my-daemon.pid', 'w')
        fp.write(str(pid))
        fp.flush()

        # Forcibly sync disk
        os.fsync(fp.fileno())
        fp.close()

        os._exit(0)
    else:
        # Child, call main
        main()
else:
    # Parent
    os._exit(0)