Fog Creek Software
Discussion Board

They call me NERD!!!

I've been working some magic on the backend of my site engine lately and have managed to squeeze an average of 500th's of a second off of the page build time... It's now currently running in the vicinity of .35 of a second.

My little heart is pounding, and a manic grin has made itself comfortable on my head. This is what I love about my job. I'm a nerd, I admit it, but damn it, I love what I do!!!

So, one and all, tell me what makes you tick! What have you done lately that's really blown your hair back?

Jack of all
Friday, November 7, 2003

Put an index on a query that made a query go from 60 seconds to 0.25 seconds.

Matthew Lock
Friday, November 7, 2003

I spent half the day writing code that generates code. It's for a class and we're working on optimization.  The code generates several hundred versions of the same function, then runs and clocks 'em.

The instructor was able to get a speedup of 1.8 over the original and considers that a pretty good number since he also "considers himself a pretty good coder."

I'm at 2.5 and rising.

Friday, November 7, 2003

That's a pretty cool idea Nick, generating code to try possible permutations of an idea, then test them.

Matthew Lock
Friday, November 7, 2003

Considering high performance server architectures that use Asynchronous I/O to process requests. 

BTW if Ori is still here, I figured out how those Python guys wrote a single threaded web server.  Python supports co-routines which are similiar to user mode threads like NT fibers.  At least the problem can be broken down that way.  It makes the state machine MUCH easier to program.

Engelschall's Pth allows a similar mechanism.  It is a smart way to build a server, but it isn't exactly what I thought.  I was thinking more along the lines of Doug Schmidt's Proactor pattern. 

I took a look at Schmidt's JAWS web server, and realized he buffered a lot of data before processing it.  That's the easy way out, and a good way to get yourself into a buffer overflow problem.

But anyways.

christopher baus (
Friday, November 7, 2003

At high saturation AIO help give you that 30% boost if jobs for AIO and thread based workers can be handled pretty quickly. For long running jobs the benefit disappears. For tiny jobs with thousands of clients waiting AIO really shines. For single thread jobs with 4 consumers, don't even bother with AIO.

Li-fan Chen
Friday, November 7, 2003

There are maybe 3 key caching methods that's of any interest to the overworked web coder who has no time for any decent infrastructure.

There's cmd_memoire, which builds a shared-memory hash string structure in the web server that caches the answers (especially long answers) of the Most Recently/Often Used distinct queries. Where the key lookup is context|command_name|command_parameter or something like that MD5 digested. This is pretty cool as long as you have an weekend to code this up.

It does two things: identical queries made by the same web server will have instant answers from memory without hitting the rdmbs. You have to figure out the expiration policy ofcourse.

Source: found it in Arsdgita Community System (go check out OpenACS)

The second method is basically an enhancement of the first method, you add triggers to the database and a rule system that helps you figure out what sort of updates to your database system should result in the proper expiration of an memoired answer.

The third method is basically trying to make blade systems work with tons of hardware redundancy and scalability at the tcp level none of us has any kind of access to. Check out research by akamai and ibm olympic website team (circa 1996,1998)

If you want to go N level.. you'll have to look at one of my college friend's work on connection resumption between the network access point at any given server in the server farm. That basically allows you to scale even more--probably even better than the way google does. See
But then if you care about this kind of competence you probably already read the article and talked to the author back early last year.

Li-fan Chen
Friday, November 7, 2003

The common theme from my previous 2 posts are this: look at the nature of your data. If you have been asking an inefficient framework to do a lot of file shuffling you'll waste a time doing a lot of bandwidth wasting, disk seeking, memory block copying, internet explorer icon spinning before your server get any chance to do the intersting stuff. So if you apply even one of the rules from above. It will probably allow you write web apps that wont' have to get stuck in the RDMBS/network file acess mud.

Li-fan Chen
Friday, November 7, 2003

Think about CityDesk for example. What does the free version do? Pre-parses
    1) some custom logic from you
and use those directives to do something interesting with the latest
    2) almost live data and fresh enough creatives/templates/copy
and then punch out <50
    3) html pages that no browser/webserver/database in the world has to cough up a single extra cycle of dynamic processing to push out. Static push all the way.

Now multiply your 20 custom directives by 200 programmer man years. Multiple those creative by the number of staff at AP Press, and then multiply your 20 hits a month by a few million a day. And you got yourself a situation where you are plenty thankful you preparsed everything. And could do it (in a batch job) fashion again 60 seconds from now. And again--so on and so forth--providing almost live coverage of whatever the hell is going on in the world that's keeping millions of house wife up at night--without wasting an astronomical amount of database access or network file sharing or memory copying or visit thumb twiddling...

I know we are talking about CityDesk here, not exactly ready for AP just yet--but that's how the IBM olympic website does it; they have a big team of people who created a custom job that basically does what CityDesk does (pre-parsing, generating almost live data)... and some how plug it into their farm. That's how they serve 5 million hits a minute--should they ever need to.

So if you are even mildly successful at scaling one of the three factors (many visitors per second/many live content/many directives).. you'll appreciate something like CityDesk right away.

I realized something like this 5 years ago, and that was a good day.

Li-fan Chen
Friday, November 7, 2003

Getting a credit card check digit calculation to run 1/4 second faster.

Yes, a whole 0.25 seconds.

Mind you, the system only ran at 32 instruction per second.  Not a misprint.

Friday, November 7, 2003

32 instructions per second? Pah! In my day we had to write the instructions by hand and send them in by carrier pigeon.

Friday, November 7, 2003

Take a look at erlang's lighweight process architecture
for performance.

Yaws is a erlang web server
that kicks ass.

son of parnas
Friday, November 7, 2003

The most recent thing that blew me was blonde, six foot something, and certainly worth the climb

protect the guilty
Friday, November 7, 2003

> The most recent thing that blew me was blonde, six foot something, and certainly worth the climb

What was his name?

Mr Obnoxious Man
Friday, November 7, 2003

In my last job they were using a training administration system that took about eight hours to run budget reports (I kid you not). I wrote a little system in Access that programmatically coped the relevant data files, indexed them and ran the reports. It turned out to be at least 15,000% faster! That felt pretty good.

Now I work with J2EE and all I can do is try to keep up with whatever the latest open source fad-of-the-month is! ;-)

John Topley (
Friday, November 7, 2003

I convinced a billion $/year Chemical company to finance my vaporware (albeit, modestly) for 3 years in exchange for 100 licenses. 

I had no background, experience or training short of writing some macros in AutoCAD and I actually ended up with a product.

That was a very good day.

Friday, November 7, 2003

Phizo, can you do my marketing?

christopher baus (
Friday, November 7, 2003


never mind the marketing. lets do a post Google IPO.

Easy money here we come!!

Friday, November 7, 2003

*  Recent Topics

*  Fog Creek Home