Optimisation: sometimes the best move is not to play

Posted by bert hubert Sun, 09 Apr 2006 22:18:00 GMT

Spent some time this weekend setting up my father’s holiday location, which was very good. Time flew by and we had to race to pick up my car, which was on a company property that would be locked up at night. His new place has Wifi, but he is too far removed from the access point. I ordered a very nice directional antenna from the Wifi Shop, hope it shows up soon. Aiming it should be hard work, as getting line of sight requires mounting the antenna on a large pole. Should be worthwhile though!

Movies & PowerDNS

As regular readers of this blog will know, I’m currently working hard on making the PowerDNS recursor the fastest and most ablest nameserver on this planet.

To this end, I’ve done a lot of micro-optimisation, which means trying to make individual functions as fast as possible. Time and time again however, I’ve discovered that gcc 4.1 does a very fine job already.

Until I started finding very major optimisations, which remind me of one of my favorite movies, War Games, which has a famous quote, ‘Sometimes the best move is not to play’. This has turned out to be very apt.

The best way to speed up a program on a modern platform.. is by making it do less. So I spent some time doing that. DNS at its core is case-insensitive, so www.powerdns.com is equal to WwW.PoWeRdNs.CoM. There are basically two ways do go about this. The first is to first lowercase everything, the second is to make your comparison functions case-insensitive.

The problem with the first solution is that, while allowed, many DNS clients will react badly when they receive an answer for ‘www.google.com’ when they asked for ‘WWW.GOOGLE.COM’. So you have to keep the original question around. This costs memory, and time.

Previously PowerDNS followed approach 1. I’ve now moved it to true case insensitvity. I also solved the strange and murky world of the trailing dot, ‘www.google.com’ versus ‘www.google.com.’.

Al this proved to be a small speedup, but it feels a lot better now lowercasing everything all the time.

Even bigger news in the ‘not to play’ department was short-circuiting the whole wonderful MOADNSParser (mother of all etc) structure. This system is wonderful, a joy to program, and about as efficient as it can get while remaining safe.

However - to decode and encode A, CNAME and NS records, it is overkill. So, large parts of PowerDNS now do those records by hand, saving a lot of malloc/free (new/delete) calls. Especially for A records, which constitute the bulk of all queries, this makes a big difference.

I wonder very much why I did not do this earlier, but I think it is because I love the MOADNSParser too much. I should be honest however and know that it is overkill to use so much code for parsing the 4 bytes of an IP address!

PowerDNS appears to be 20-30% faster because of the work today. On FreeBSD, a loaded PowerDNS now spends 25% of its time in the kernel, which tells me we are doing all right.

Posted in , , ,  | 8 comments | no trackbacks

Comments

  1. hydrocodone said 181 days later:
    Hello all really cool blog alprazolam fioricet hydrocodone vicodin tramadol xanax valium ultram soma carisoprodol ambien ativan lorazepam propecia adipex didrex cialis levitra paxil meridia viagra wellbutrin clonazepam xenical prozac butalbital phentermine buy ativan buy adipex buy didrex buy levitra buy cialis buy phentermine buy soma buy tramadol buy diazepam buy carisoprodol buy meridia buy paxil buy valium buy xanax buy ultram buy fioricet tooth whitening online pharmacy alprazolam car insurance payday loan web directory business directory carisoprodol hydrocodone buy vicodin
  2. diet pills said 411 days later:
    Aciphex Cialis Lipitor Prevacid Propecia Ultram Viagra
  3. diet pills said 411 days later:
    nice blog
  4. diet pills said 411 days later:
    Aciphex Cialis Lipitor Prevacid Propecia Ultram Viagra
  5. buy cialis said 411 days later:
    Aciphex Cialis Lipitor Prevacid Propecia Ultram Viagra Viagra Soft Tabs Zyrtec Allegra Atarax Clarinex Claritin Effexor XR Pamelor Paxil Zyprexa Neurontin Amoxil Cipro Zithromax Arava Singulair Adalat Altace Avapro Cardura Coreg Coumadin Cozaar Isoptin Lopressor Norvasc Plavix Tenormin Crestor Mevacor Pravachol Zocor Actos Amaryl Avandia Glucophage Glucotrol XL Lasix Protonix Zantac Imitrex Nexium Prilosec Breast Success Enhance9 Euphoria Cologne Euphoria Perfume Female Rx Oil Female Rx Plus Hoodia Gordonii Hoodia Patch Human Growth Agent Joint Formula Liquid Rx Plus Multi Vitamin Premium Diet Patch Super Greens Virility Patch Rx Virility Pills VPRx Oil Yerba Diet Zero Nicotine Patch Lotensin Caverta Cialis Soft Tabs ED Trial Pack Flomax Kamagra Kamagra Oral Jelly Levitra Silagra Tadalis SX Lioresal Soma Celebrex Lamisil Oral Retin-A Zyban Synthroid Florinef Xenical Clomid Evista Fosamax
  6. buy cialis said 411 days later:
  7. Contact Us
  8. F.A.Q. and Help
  9. Shipping time and costs
  10. Refund and returns
  11. Shopping Cart
  12. Privacy policy
  13. Terms of Use
  14. buy cialis said 411 days later:
    bentley
    rolls royce
    holden
    mercedes benz
    mitsubishi
    land rover
    lada
    lexus
    saab
    nsu
    detomaso
    lamborghini
    volvo
    dacia
    tvr
    maybach
    ferrari
    pontiac
    chrysler
    morgan
    trabant
    renault
    plymouth
    alpina
    cobra
    smart
    skoda
    gmc
    maserati
    toyota
    suzuki
    daihatsu
    fiat
    austin healey
    triumph
    mahindra
    lincoln
    aston martin
    corvette
    proton
    hyundai
    lancia
    audi
    seat
    ssangyong
    bmw
    borgward
    acura
    talbot
    jeep
    ligier
    kia
    piaggio
    citroen
    buick
    oldsmobile
    porsche
    lotus
    rover
    tata
    cadillac
    subaru
    bugatti
    wiesmann
    landwind
    daewoo
    honda
    santana
    caterham
    asia motors
    infiniti
    mg
    austin
    mazda
    alfa romeo
    mini
    opel
    dodge
    hummer
    peugeot
    nissan
    ford
    isuzu
    chevrolet
    jaguar
    vw
    wartburg
  15. fuck the glamour said 411 days later:

Trackbacks

Use the following link to trackback from your own site:
http://blog.netherlabs.nl/articles/trackback/25

Comments are disabled