Posts

Showing posts with the label tech

Act IV, Scene I

- what wizardry is this!? svn supports symlinks? A dark Filesystem. In the middle, a Repository boiling. Thunder.                  Enter the three  Programmers.        1 P ROGRAMMER.   Thrice the padded buf hath oe'r runn'd.        2  P ROGRAMMER .   Thrice and once, the platter spun.        3  P ROGRAMMER .   Hexate cries:—'tis time! 'tis time!        1  P ROGRAMMER .   Round about the repo go;     In spaghetti'd source code throw.—     Functors, that on blackest ARM,     Caused a user grievous harm;     Refactor'd business logic got,     Compile first i' the charmed pot!        A LL.   Double, double toil and trouble;     Cycles burn, and repo bubble.        2  P ROGRAMMER . ...

Multithreaded Python, extensions, and static data

The GIL The GIL and Context Switching I use Boost.Python to write some C++ extensions for Python. I work on an I/O-bound Python program; Python has a global interpreter lock ("the GIL") which means that in a multi-threaded program, only one thread can be executing code inside the Python interpreter at once. Now, a thread can drop the GIL, and the built-in Python read and write routines do this so that while one thread is doing I/O, another thread can run. However, due to a peculiarity in how the GIL is implemented, 1 even though the actual I/O takes place during system calls that drop the GIL, the need to re-acquire the GIL after every I/O operation was killing our performance. For instance, one of the things that the application does a lot of is logging. Doing the logging synchronously -- as the code is executing and it wants to write something to its log, it needs to wait for the write to the logfile to finish before it can continue going about its business -- turned...

Sloppy Graph, Sloppy Design

Image
I was spending time trying to fine-tune a graphviz file documenting the call graph of a piece of code and describing some of the critical functions. graphviz isn't really designed for the kind of long node labels I wanted to give it, so it would do things like put nodes in places which made it have to draw arrows reaching clear across the page. Finally I realized that rather than trying to talk graphviz into reordering its nodes, I could just refactor the thing I was graphing so that the flow wasn't so darned convoluted in the first place. Before (image links to full size version): After (image links to full size version): Corollary? If it's hard to get your call flow graph to look pretty, well, the graph isn't the only thing that's ugly...

Switching Finks

One of the open-source projects I contribute to is Fink , a package manager for OS X; if you've used apt-get or yum on Linux, it provides a similar facility, allowing you to install, say, GnuPG by running fink install gnupg . It installs things into its own directory tree, rooted at /sw by default, to avoid interfering with things shipped by Apple ( / , /usr ) or manually installed by the user ( /usr/local .) That is, if you have Fink installed, your system will have /sw/bin , /sw/lib , /sw/etc , /sw/share/man , &c. So that you can run things installed in these nonstandard locations, Fink provides some shell commands in /sw/bin/init.sh which edit environment variables like PATH and MANPATH to include the /sw/* directories. Most Fink users have . /sw/bin/init.sh in their ~/.profile , so these commands will be invoked when their shell starts. Having my shell automatically pull in Fink at startup doesn't work for me, though. It's important to me to have a clea...

For All Your Finger-Pointing Needs

While working with a large codebase, I often want to find the origin of a particular line. Subversion offers a tool, annotate (aka blame , aka praise ), which displays the author and revision for every line in a file, indicating who made the last change to a line. However, the last change is often not very useful; it was a minor change as a result of some other change you're not interested in, or the code was moved around due to refactoring, and you need to go back even further. When I need to do this, I find myself doing a sequence of: 1. svn blame FILE | less ; find the revision N where the line was last changed 2. svn log -r N FILE | less ; if the change is interesting, read the commit log for the file 3. svn blame FILE @ N-1 | less ; using Subversion's little-known pinned revision syntax, find the previous time the line was changed 4. Using N-1 as the new N , return to step 2. : Pretty much any Subversion command that takes a path argument can be given PATH @ REVIS...

Wrong Dates in iCal Birthday Calendar

Image
To keep track of people's birthdays, I use Mac OS X's Birthday Calendar feature of Address Book/iCal. I was going through my calendar the other day, and I noticed that a birthday which I knew was sometime in January wasn't showing up. It was on the corresponding Address Book contact, though. I deleted the birthday from this contact and reentered it, which fixed that entry, but on the suspicion that more birthdays might be missing, I flipped through my calendar and found: The Address Book birthday field has the misfeature that it forces a year to be specified. What a rude thing for Address Book to be asking! Anyway, I'd arbitrarily picked year 1 for the year for any contacts whose birth years I didn't know. Maybe, I thought, the Gregorian reform was throwing things off. However, changing the year to 1900 didn't help matters, and in fact made them worse: Turning the birthday calendar off (which wipes out iCal's backing store for the calendar) an...

Internationalization of Names

Names are complicated What's in a name? The answer turns out to vary quite widely around the world. When an English-language form, either electronic or paper, asks for a person's name, it usually provides separate fields for first and last name, and sometimes middle name or middle initial. Aristotle Pagaltzis linked to a post by Jim Clark on Thai names, demonstrating that this approach, or even the alternative "given name, family name", falls down pretty quickly outside the English-speaking world. Thai names consist of: A given name, similar to the English first name, except that it must come from a list of government-approved names; A family name, which is also government-regulated; all people with the same family name are related, and new Thai citizens must select an unused name. Like all non-namespaced identifiers (domain names, instant messenger handles, user names on popular web services), the good short ones are taken; and A chue len , which is typica...

Migrating a wiki from Trac to MediaWiki

I'd set up a Trac installation for wedding planning, instead of using MediaWiki (the system Wikipedia uses, which I already had a couple of installations of) since we wanted both a wiki (venue data, possible honeymoon destinations, guest lists... shut up, it's useful!) and ticket system (useful for tracking things like thank-you notes and being able to assign specific ones to either Liz or myself). However, Dreamhost doesn't support mod_python, so pages were taking way too long to load. I decided to switch over to MediaWiki for the wiki part and just use my existing Bugzilla installation for ticket tracking. Hence, a new script over on the code page, trac2mw . Our wiki was fairly tiny, so caveat user. I didn't bother having it migrate tickets tickets or attachments, since we didn't have any data there that was worth preserving. The input format, a MySQL XML dump, probably isn't ideal for a lot of people (since Trac runs on SQLite by default.) It does fi...

Why Subnets are Good: The Party

(This is an attempt to explain, to a non-technical audience, why a large network, such as the Brandeis network, should be divided into subnets. It comes from this bboard thread .) The reasons why one wouldn’t want to have the entire campus be one huge subnet are technical, but I’ll try to explain them. Think of the Brandeis network as a huge party. It’s a tremendous party, with every student, faculty-member, and staff-member in one huge room. The university is sponsoring it to celebrate the grand opening of the Carl and Ruth Shapiro Supremely Massive Empty Room. You think your friend Alice is at the party, and you want to talk to her. So, you have to find her. You don’t know where she is in the massive room, so you have to either shout really loudly, or spend a lot of time looking for her. Everyone else is also trying to find people, so everybody’s shouting and running around. Furthermore, people are trying to get to different places in the ...

When Daemons Attack: Debugging Linux Applications

Notes from a talk I gave to the Brandeis University Computer Operators Group. Call tracing System call tracing — strace (Linux), truss (BSD), strace for NT Library call tracing — ltrace (Linux/BSD) Trace example ( ltrace -S ) First, the program is linked and loaded… SYS_uname(0xbffff600) = 0 SYS_brk(NULL) = 0x0804c000 SYS_open("/etc/ld.so.preload", 0, 010000210574) = -2 SYS_open("/etc/ld.so.cache", 0, 00) = 3 SYS_fstat64(3, 0xbfffeda0, 0x400114ac, 0, 0x400115e4) = 0 SYS_mmap(0xbfffed70, 0, 0x400114ac, 3, 0x40011594) = 0x40012000 SYS_close(3) = 0 SYS_open("/lib/libc.so.6", 0, 027777767210) = 3 SYS_read(3, "\177ELF\001\001\001", 1024) = 1024 SYS_fstat64(3, 0xbfffedf0, 0x400114ac, 0, 0x400115e4) = 0 SYS_mmap(0xbfffecd0, 0x40011d30, 0x400114ac, 2, 0xbfffecf0) = 0x40029000 SYS_mprotect(0...