Random notes from mg

a blog by Marius Gedminas

Marius is a Python hacker. He works for Programmers of Vilnius, a small Python/Zope 3 startup. He has a personal home page at http://gedmin.as. His email is marius@gedmin.as. He does not like spam, but is not afraid of it.

Mon, 14 Mar 2005

I took the commonly confused words test

Advanced

You scored 100% Beginner, 100% Intermediate, 93% Advanced, and 66% Expert!

You have an extremely good understanding of beginner, intermediate, and advanced level commonly confused English words, getting at least 75% of each of these three levels' questions correct. This is an exceptional score. Remember, these are commonly confused English words, which means most people don't use them properly. You got an extremely respectable score.

Thank you so much for taking my test. I hope you enjoyed it!

For the complete Answer Key, visit my blog: http://shortredhead78.blogspot.com/.

My test tracked 4 variables How you compared to other people your age and gender:

You scored higher than 68% on Beginner
You scored higher than 73% on Intermediate
You scored higher than 48% on Advanced
You scored higher than 32% on Expert

Link: The Commonly Confused Words Test written by shortredhead78 on Ok Cupid

I answered questions 22, 31, 33, 36, 38, and 40 incorrectly.

posted at 02:24 | tags: | permanent link to this entry | 0 comments

Sun, 13 Mar 2005

Measuring disk speed

A friend of mine told me yesterday that he got a significant disk access speed improvement by moving his Linux partition from the end to the beginning of the disk. The theory being that lower disk sectors are located on the outer rim, and are faster, because the disk rotates at a constant angular speed. I didn't believe this could give a 50% improvement, so I decided to do some benchmarking.

hdparm -t /dev/hda on my disk gives me transfer speeds between 20 to 24 MB/s on my 40 GB laptop disk. I hacked hdparm.c to seek to the end of the device, minus the number of sectors hdparm reads to determine disk speed, and ran it. I got a read error instead of a speed estimate. My 40 GB disk has an inaccessible Host Protected Area of about 4 GB at the end, and although the kernel claims it disabled the HPA, reading it gives me I/O errors.

I then changed my hack to skip the HPA as well, ran it, and got 3.5 MB/s. Wow, I thought. I never thought the difference could be so significant. I ran the regular hdparm to double-check, and got 3.5 MB/s again. Wait a minute... It turned out that the kernel saw disk I/O errors from the HPA, and decided to disable DMA. After a quick hdparm -d 1 /dev/hda, I once again saw 24 MB/s at the beginning of the disk, and almost the same value at the end:

mg@perlas:~/src/apt-sources/hdparm-5.8 $ for i in 1 2 3; do sudo hdparm -T -t /dev/hda; done

/dev/hda:
 Timing cached reads:   844 MB in  2.01 seconds = 420.80 MB/sec
 Timing buffered disk reads:   74 MB in  3.07 seconds =  24.13 MB/sec

/dev/hda:
 Timing cached reads:   852 MB in  2.01 seconds = 424.79 MB/sec
 Timing buffered disk reads:   74 MB in  3.08 seconds =  24.04 MB/sec

/dev/hda:
 Timing cached reads:   804 MB in  2.00 seconds = 401.46 MB/sec
 Timing buffered disk reads:   74 MB in  3.02 seconds =  24.50 MB/sec

mg@perlas:~/src/apt-sources/hdparm-5.8 $ for i in 1 2 3; do sudo ./hdparm -T -t /dev/hda; done

/dev/hda:
 Timing cached reads:   848 MB in  2.01 seconds = 422.38 MB/sec
 Seeking to the end of device: 35573459456
 Timing buffered disk reads:   74 MB in  3.03 seconds =  24.43 MB/sec

/dev/hda:
 Timing cached reads:   856 MB in  2.00 seconds = 427.21 MB/sec
 Seeking to the end of device: 35573459456
 Timing buffered disk reads:   74 MB in  3.03 seconds =  24.39 MB/sec

/dev/hda:
 Timing cached reads:   800 MB in  2.01 seconds = 398.67 MB/sec
 Seeking to the end of device: 35573459456
 Timing buffered disk reads:   72 MB in  3.04 seconds =  23.69 MB/sec

Conclusion: physical location of a partition does not change the linear transfer speed significantly.

Multi Disk System Tuning HOWTO has a section on physical track positioning. It mentions another optimisation: if you position your partition in the middle of the disk, you will reduce average seek time by 50%. Benchmarking that is, however, more difficult than just adding an lseek call to hdparm.c, so I didn't.

posted at 17:50 | tags: | permanent link to this entry | 0 comments

Wed, 09 Mar 2005

Zope 3 request recorder

Zope 3 has this notion of functional doctests: functional tests (in the form of standalone doctest files) that pretend to perform HTTP requests to your Zope 3 server, and look at the response. Here's an example test from SchoolBell.

You can create functional doctests by using your browser and recording your session with TCPWatch, and then running a Python script that comes with Zope 3: dochttp. For some reason I found this method too cumbersome and usually just cloned existing doctests and changed the requests and responses by hand.

I now have a working prototype of a request recorder as a plug-in of Zope 3. You can set up a RecordingHTTP server on a separate port, and then go to /++etc++process/RecordedSessions.html to look at all requests you've made, filter them, and create a functional doctest.

Screenshot of /++etc++process/RecordedSessions.html

posted at 11:53 | tags: | permanent link to this entry | 0 comments

Tue, 08 Mar 2005

There's no democracy in the EU

I live in a Banana Republic. :-(

No Banana Union, No Software Patents - Support Denmark!

This is both funny and makes my want to cry: European Anti-Software Patent Bribe Pledge Drive.

posted at 00:58 | tags: | permanent link to this entry | 0 comments