Jim's Depository

this code is not yet written
 

Benchmarking a machine with a surplus of RAM introduces a difference between the first run and subsequent runs when any disk blocks needed are already cached. Fortunately, since 2.6.16 there is a mechanism to discard the caches, /proc/sys/vm/drop_caches.

I use this command to drop my caches between benchmark runs.

sync ; echo 3 > /proc/sys/vm/drop_caches

Note: that command was simplified thanks to anonymous’ comment.

As an example, building femtodns currently takes 2.1 seconds with flushed caches and 0.9 seconds on subsequent runs.

You can read more about /proc/sys/vm/drop_caches at Drop Caches - linux-mm.org Wiki

You don't need to echo 1, 2, and 3.  As the page you link to makes clear, it's a bit-mask.  Echoing 3 alone is succifient after the sync.

I’ve installed clicktoflash which stops Flash™ from running in Safari. The web is a much nicer place as a result. I detest things moving in my field of vision while I read.

Flash elements are rendered as gray rectangles, if you click on the rectangle it can run. If you Option+click, then it is whitelisted and can always run.

It could do with a little more user interface, there is really nothing visible now, but if you remember the Option+click and you never accidentally whitelist something you will be fine.

Note: If you want to remove it later, go to ~/Library/Internet Plug-Ins/ and take it out.

Attachments

Aw nuts, now I need to implement "delete attachment". The 1.3 version adds a little 'flash' badge instead of just a grey box and a way to edit your whitelist.

I've had no problems with this over the weeks I've been using it, in fact it has saved me from canceling my American Express card because their commercial no longer tries to play in my browser when I go to pay the bill.

Google watches me. Now I watch google. You will see a tiny google icon in the title bar of articles which have been scanned by the mighty G.

Following are my notes as I enable IPv6 on my servers.

  • The formatting of addresses changes. My lighttpd logs now start with addresses like ::ffff:1.2.3.3.  That ::ffff: is IPv6 speak for “an ipv4 address”. PHP5 also returns this new format when you as for \$_SERVER[‘REMOTE_ADDR’]. This has broken several bits of software that parsed addresses.

There will be more.

On the Google Finance pages you can get graphs of stocks, which if you mess with the “settings” tab, you can also display after hours trading. After hours trading is generally much lower volume and less volatile compared to normal hours. 

Notice on the image that the 7 normal hours seem rather large compared to the 17 off hours. The X axis is a nonuniform time axis, during normal hours it is 12 pixels/hour (a very programmery value to pick) but the off hours are about 7.6 pixels/hour (not a very programmery value, but perhaps it is really 23 of 12).

The end result is a harmonious display but with greater resolution in the more important data. Very nice.

(The sample graph is from the day Steve Jobs announced his medical leave from AAPL. Usually after hours is quite boring.)

Attachments

goog.gif 28691 bytes

Web surfing with U-Verse was getting annoying. I was regularly getting pages that would mostly load, but were delayed from 5 to 20 or more seconds in rendering because some elements failed to load. Noticing that the worst pages were ones with large numbers of DNS names to resolve I swapped my U-Verse supplied DNS server for OpenDNS and things became much faster. (I since swapped that to my own local bind9 because OpenDNS kept hijacking my web sites, this is also fast.)

You can see on my “time to ping google” network check exactly where I changed DNS away from AT&T’s servers.

Odd points to ponder: the DNS for www.google.com has a 5 minute life, short enough to expire between tests, but you’d think have it in cache from other client use once in a while. There is an odd quantitization in the earlier data for which I have no explanation. The other ping test running at the same time, by IP directly, does not show this effect and does not show a change at the DNS change.

******Moral:** Don’t trust your ISP for anything but packets in and out, and suspect they will screw that up too.

Note: This may or may not affect your U-Verse. I suspect they have many DNS servers and perhaps they aren’t all lame, or perhaps they have a throttling policy or something and they are all lame. Only you will know.

Attachments

dsn-change.png 20340 bytes

Today I challenge Google. I have placed a pair of google ads in the right hand column. Let’s see if Google can figure out what my depository is about. If Google chooses a coherent category for ads, I’ll replace the page subtitle with their impression of this site.

So far I’m a little insulted. They are pushing… how to say without using the word… “spectacles to protect your vision organs”, and “graphic designers”. I don’t think they care for my look.

Ack! Google is giving me annoying animated graphic ads. I signed up for "text and image" ads, apparently they consider distracting animations to be an image.
Those google ads are nice. I almost never get enticed by an ad, but two of the google ads on this site have lured me into visiting the advertiser. (Google's terms forbid me from clicking, so I have to type in the URL.)

Virtually 100% of the writing on this site is mine, so they have their little demographic cross hairs right on my brain, and it works.

I find myself missing a flow of control construct in C. Let’s say I want to locate a value which might come from a number of sources then do something with it.

if ( code == 36) value = 99; else { // a bunch of code to see if it is in the cache if ( code_in_cache(code)) value = code_from_cache(code); else { // notice how each place I have to look is  //accumulating nesting?
… }
}

If I were willing to split the code into a separate function I could just use return e.g.

int gratuitous_function( int code) { if ( code == 36) return 99;
// a bunch of code to see if it is the cache
if ( code_in_cache(code)) return code_from_cache(code);
// notice how I am not accumulating nesting?

}

That is better, but I don’t like breaking the linear flow of the program and it is likely that the function will require access to many of my local variables making a complicated interface. Worse, I may be setting several values and that gets ugly.

I generally try to cope like this…

do {

if ( code == 36) { value = 99; break; }
// a bunch of code to see if it is in the cache
if ( code_in_cache(code)) {  value = code_from_cache(code);  break;  } // notice how I am not accumulating nesting? … } while(0);

That works fine until I locate the value inside a for loop, then the break will take it out of the for loop.

I think what I really want is a named block…

block foo {

if ( code == 36) { value = 99; break foo; }
// a bunch of code to see if it is in the cache
if ( code_in_cache(code)) {  value = code_from_cache(code);  break foo;  } // notice how I am not accumulating nesting? … }

I guess I could always be a barbarian just use a goto and a label.

Why not simply:

if (code == 36) {
   value = 99;
} else if (code_in_cache(code)) {
   value = code_from_cache(code);
} else if (...) {
   // Notice how there is no nesting?
}

Oh, I neglected the "// a bunch of code to see if it is in the cache" part.  Yeah, don't be afraid of using goto-s.  There's nothing wrong with them when used properly.
Yes, it is that bit of logic that makes the } else if { not work.

I installed SLOCCount today on my development machine. You can run it from one of your source directories like… sloccount *.[hc] … and it will tell you not only how many lines of code you have but what it may have cost to write them. So far I’ve written \$15k of code today. I can’t find the right command line option to get it to deposit that in my account.

Since I last wrote on the topic, Into the world of Virtual Hosting, I’ve split my server into two with this part being on a new virtual hosting operation. I chose RapidXen because it has IPv6 support, and is cheap. I’m using a 128M RAM/10G disk package for \$83/year, which is about the same as my 64M/2.5G package over at VPSLink.  

  • The RAM change is a little deceptive, the RapidXen box is a 64 bit machine, so a good part of the extra RAM just goes to cover that bloat.
  • The RapidXen machine is many times faster.
  • The VPSLink machine has become much slower as time has gone on. I can’t tell if they are loading the machine more heavily, or if some IO pig has moved into my server, but life is not as good as it used to be.
  • RapidXen is a smaller operation, I had to wait for a human during the setup.
  • My IPv4 address at RapidXen was pre-blocked as a spam source by AT&T, but no other black lists I could find. Sometime worth checking when you get a recycled IP.
  • You apparently have to open a trouble ticket and ask for console access to your server at RapidXen, I haven’t completed that yet. At VPSLink it is available by default with a Java based SSH client.
more articles