Monthly Archives: January 2008

Download: Eject USB Drives in Just One ClickLifeSpy

USB Disk EjectorIf you’re a big fan of portable storage – USB flash disks, external hard drives, even your iPod – you know the annoyance brought about by having to eject them first from your OS before yanking off the USB plug. It’s a two-stroke process for Windows users (left clicking that icon in the system tray and selecting the device from the list or if you’re doing that two-dialog right-click option).

Another problem with Windows XP is that, if you have, multiple devices connected, it doesn’t really specify which one is which. Oh and that error message saying you can’t remove the hardware because it is in use message even if the device is absolutely idle and you’re not running anything at all.

So that’s when we thank the freeware gods for this nifty tool. USB Disk Ejector is a small and portable application that offers you a one-click solution to ejecting them devices. You have the option to run it via command line or a GUI. Best of all, it can be part of your Swiss Army flash disk arsenal of portable tools. It works even when run on the portable device.

Download USB Disk Ejector here.

COALESCE function instead of long CASE WHEN … ELSE (T-SQL).NET Tip of The Day.org

Instead of using long “SELECT … CASE WHEN … ELSE …” construction, you can use the COALESCE function when you need to find a value that is not NULL. Lets review the following T-SQL expression, in which we need to select an available “source”:

SELECT TheSource =

   CASE

      WHEN localSource IS NOT NULL THEN localSource

      WHEN intranetSource IS NOT NULL THEN intranetSource

      WHEN internetSource IS NOT NULL THEN internetSource

      ELSE

   END

FROM

Now lets rewrite the code above using COALESCE function:

SELECT TheSource =

   COALESCE(localSource, intranetSource, internetSource, )

FROM

The tip applies to MS SQL Server 2000/2005.

Firefox Quick Tip: Know What’s Behind TinyURL Links with Greasemonkey ScriptLifeSpy

TinyURL Popup Preview

I love TinyURL. While you don’t see me using them generated links here. I use them quite often in my other blogs. Posting links in Twitter is probably the most practical use I have for it save for the obvious trimming of thousand-character long URLs. But as a security cushion, wouldn’t you want to know what’s behind the link first before you go clicking? Too bad TinyURL links just don’t quite show you where they lead until after you click them.

That’s where Greasemonkey and scripts become quite handy (yet again). If you haven’t got any clue what’s with Greasemonkey, read up.

Anyway, here’s TinyURL Popup Preview. It allows you to see what link is behind the TinyURL link by hovering on the link. The ‘real’ link will show up as with TITLE tags. No more guessing on what lies behind the link.

Install the TinyURL Popup Preview from here.

Old TV becomes a bar

Bar Closed
Bar Open
Bar Top
AlpineButterfly writes in -

A good friend of mine offered up an old style cabinet TV.. and for some reason it called out to become a bar! Thank you Sally! This project is an experiment in MANY ways. It’s the first time I tackled grouting. First time I’ve cut glass. First time I sewed a curtain. Because of all these firsts… I was scared to invest moula and the result is that it is also recycled in many ways! The TV insided have been brought away to stay out of a land fill. The shelves, are mostly pieces of old mdf board that have been in the attic since my move… (they weren’t deep enough so I ended up gluing multiple ones together). The MP3 player drawer… is a cigar box, found somewhere. The speakers, which you can’t seen.. we also an attic find.

Old TV becomes a bar! – Link.

[Read this article] [Comment on this article]

DIY Magnet sculpture

2187963032 5B4F33Ecb4
2188081386 19F95Bffd1
MAKE Flickr photo pool member Cmorris32839 made a really DIY magnetic sculpture – Link.

[Read this article] [Comment on this article]

How many open files the system can handle?

Linux:

# cat /proc/sys/fs/file-max
# cat /proc/sys/fs/file-nr

The last command line will return three numbers; first total allocated file descriptors, second total free allocated file descriptors, and last maximum open file descriptors.

Latency bubbles in your disk IO

The following was written in response to an email from a customer about monitoring IO in response to my scsi.d postings. Tim covers where disk IO requests can be queued in his posting titled “Where can I/O queue up in sd/ssdwhich I would recommend as a starting point.

The disk IO sub-systems are built to provide maximum through put which is most often the right thing. However the weakness of tuning for throughput is that occasionally you can get some bizarre behaviour when it comes to latency. The way that optimum IO bandwidth is achieved is by sorting each io by logical block address (LBA) and then issuing those in order to minimize head seek. This is documented in the disksort(9F) manual page.

So if you have a sequence of writes to blocks N, N+1, N+2, N-200, N+3, N+4, N+5,N+6, N+7 in that order and your LUN as a queue depth and therefore throttle of 2.1 The IO’s will actually be delivered to the LUN in this order N, N+1, N+2, N+3, N+4, N+5,N+6, N+7, N-200. Hence there will be a significant latency applied to the IO going to LBA N-200 and in practice it is possible to have IO requests delayed on the waitq for many seconds (I have a pathological test case that can hold them there for the time it takes to perform an IO on nearly every block on the LUN, literally hours). You better hope that that IO was not your important one!

This issue only comes into play in the disk driver has reached the throttle for the device as up until that point each IO can be passed straight to the LUN for processing.2 Once the driver has reached the throttle for the LUN it begins queuing IO requests internally and by default will sort them to get maximum throughput. Clearly the lower the throttle the the sooner you get into this potential scenario.

Now for the good news. For most disk arrays sorting by LBA does not make much sense since the LUN will be made up of a number of drives and there will be a read cache and a write cache. So for these devices it makes sense to disable disksort and deliver the IO requests to the LUN in the order in which they are delivered to the disk driver. If you look in the source for sd.c you will see that we do this by default for most common arrays. To achieve this there is a flag, “disable disksort”, that can be set in sd.conf or ssd.conf depending on which driver is in use. See Micheal’s blog entry about editing sd.conf. While you are reading that entry note you can use it to set the throttle for individual LUNS so you do not have to set [s]sd_max_throttle, which will penalize all devices rather than just the one you were aiming for. If you have just one that only has a small queue depth and you will see below why a small queue depth can be a really bad thing.

So how could you spot these latency bubbles?

It will come as no surprise that the answer is dtrace. Using my pathological test case, but with it set to run for only 10 minute to a single spindle, the following D produces a clear indication that all is not well:

fbt:ssd:ssdstrategy:entry, fbt:sd:sdstrategy:entry
{
      start[(struct buf *)arg0] = timestamp;
}
fbt:ssd:ssdintr:entry, fbt:sd:sdintr:entry
/ start[(this->buf = (struct buf *)((struct scsi_pkt *)arg0)->pkt_private)] != 0 /
{
       this->un = ((struct sd_xbuf *) this->buf->b_private)->xb_un;
       @[this->un] = lquantize((timestamp - start[this->buf])/1000000,
            60000, 600000, 60000);
       @q[this->un] = quantize((timestamp - start[this->buf])/1000000);
       start[this->buf] = 0;
}

This produces the following output3, the times are milliseconds:

dtrace: script 'ssdrwtime.d' matched 4 probes ^C
6597960853440
        value  ------------- Distribution ------------- count
      < 60000 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 377204
        60000 |                                         0
       120000 |                                         0
       180000 |                                         0
       240000 |                                         0
       300000 |                                         0
       360000 |                                         0
       420000 |                                         0
       480000 |                                         2
       540000 |                                         300
    >= 600000 |                                         0
6597960853440
        value  ------------- Distribution ------------- count
           -1 |                                         0
            0 |                                         40
            1 |                                         9
            2 |                                         6
            4 |                                         17
            8 |                                         23
           16 |                                         6
           32 |                                         36
           64 |@@                                       15407
          128 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   361660
          256 |                                         0
          512 |                                         0
         1024 |                                         0
         2048 |                                         0
         4096 |                                         0
         8192 |                                         0
        16384 |                                         0
        32768 |                                         0
        65536 |                                         0
       131072 |                                         0
       262144 |                                         0
       524288 |                                         302
      1048576 |                                         0

Now recall that my test case is particularly unpleasant but it demonstrates the point. 300 IO requests took over 9 minutes and they only actually got to complete as the test case was shutting down. While the vast majority of the IO requests complete in less than 256ms.

Now lets run the same pathological test with disksort disabled:

dtrace: script 'ssdrwtime.d' matched 4 probes
^C
6597960853440
value  ------------- Distribution ------------- count
< 60000 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 543956
  60000 |                                         0
6597960853440
value  ------------- Distribution ------------- count
   -1 |                                         0
    0 |                                         30
    1 |                                         21
    2 |                                         30
    4 |                                         0
    8 |                                         0
   16 |                                         50
   32 |                                         3
   64 |                                         384
  128 |                                         505
  256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  531169
  512 |@                                        11764
 1024 |                                         0

Notice that now the majority of the IO requests took longer now, falling in the 256ms bucket rather than the 128ms bucket but none of the IO requests took many minutes.

Now my test case is pathological but if you have drives with small queue depths and disk sort is still enabled you are open to some quite spectacular latency bubbles. To mitigate this my advice is:

  1. Don’t ever set the global [s]sd_max_throttle in /etc/system. Use the [s]sd.conf file to set the appropriate throttle for each device.

  2. Consider what is more important to you. Throughput or latency. If is is latency or if your LUN is on a storage array then turn of disksort using the [s]sd.conf file.

  3. If you have pathological applications then understand that the IO subsystem can give you throughput or bounded latency, not both. So separate out the IO devices that need throughput from those for which latency is more important.

  4. Be aware that even “dumb” disk drives often implement disk sort internally so in some cases they can give a similar issues when they have a queue depth of greater than 24. In those cases you may find it better to throttle them down to a queue depth of 2 and disable disksort in [s]sd to get the most predictable latency all be it at the expense of throughput. If this is your issue then you can spot this either by using scsi.d directly or by modifying it to produce aggregations like those above. I’ll leave that as an exercise for the reader.


1The queue depth of a LUN is the number of commands that it can handle at the same time. The throttle is usually set to the same number and it used by the disk driver to prevent it sending more commands than the device can cope with.

2Now the LUN itself may then re order the IO if it has more then two IO’s in it’s internal queue.

3Edited to remove output for other drives.

4With a queue depth of 2 the drive can not sort the IO requests. It has to have one as active and the next one waiting. When the active one completes the waiting one will be actioned before a new command can come from the initiator.

Create a Keyboard Shortcut for Any Menu Action in Any Program [Mac OS X Tip]Lifehacker

add-shortcut.pngMac OS X tip: Nothing’s more heartbreaking to a keyboard lover than discovering that a common application action is lacking a keyboard shortcut. Luckily OS X makes it wildly simple to add new shortcuts for any action available in the menu bar. Here’s how it works:

Open the Keyboard & Mouse preference pane in your System Preferences and click on the Keyboard Shortcuts tab. Click the little plus (+) sign, choose the application you want to assign a shortcut for from the drop-down, then enter the exact name of the menu bar item you want to execute (for example, I want a shortcut to resize an image in Preview, so I'm using "Adjust Size…"). Then just pick your keyboard shortcut, click Add, and voilà—you've successfully added a new shortcut to your Mac. When you open the app, you'll notice that shortcut is even visible next to the item so it'll be easy to remember.

This option should be available for every modern operating system, but unfortunately it’s not. Windows users can still turn any action into a keyboard shortcut (specifically, check the Restrict Your Hotkey to a Specific Application section), but it requires a bit more work.




Easy Desktop Customization with Ubuntu Tweak [Featured Linux Download]Lifehacker

ubuntutweak_cropped.jpg
Ubuntu Linux only: Ubuntu Tweak is a small customization tool that gives you a single access point to some of the interface and file browsing options tucked away in Ubuntu’s advanced preferences or text configuration files. Along with a few of the more common Compiz Fusion and interface preferences, Ubuntu Tweak lets you enable useful functions for CD burning, easily enable and change splash screens, make advanced power management changes, and even lock down certain tools for security reasons. Experienced users may know how to change a lot of things in this app, but for new installs, and new users, it’s a time saver. Ubuntu Tweak is a free download for Ubuntu Linux systems.




Use Google Web History WIthout Installing a Toolbar [Google]Lifehacker

webhistory_cropped.jpg

The Google Operating System blog has a helpful, quick guide on how to enable Google Web History for more than just Google searches without having to make the usual Google Toolbar installation, using JavaScript-based tools like Greasemonkey for Firefox, Trixie for Internet Explorer, and Safari, Opera, and Konquerer (KDE Linux) also. You still need to be logged into a Google account to enable history tracking, but it could be a real help to those using alternative browsers for which the Toolbar isn’t offered. And while many users certainly still have their privacy concerns about Google knowing everywhere you’ve been browsing, disabling the non-Google portion is as simple as turning off the script.




WP Like Button Plugin by Free WordPress Templates