Category Archives: microsoft

What’s Magical About 1272 Bytes?

So here’s a bit of Windows Vista Ultimate 64-bit arcana for you… I was doing some research on the performance and efficiency of relative cluster sizes, and because of this I wanted to know how many files of certain sizes were on my disk. So I started running some searches, with various cluster sizes that I was considering, hoping to get some data points against which to run some statistical analysis. Here’s what I ended up with, running Vista’s file search in “non-indexed” mode, and choosing to include hidden and system files:

File SizeFile Count
<64KB72,781
<16KB53,480
<8KB42,696
<4KB31,542
<2KB15,822
<1KB19,528
<0.5KB10,058

Did you notice something odd? That’s right, the number of files <1KB in size is greater than the number of files <2KB in size! This is mathematically impossible, of course.

Using a manual binary search algorithm, I finally arrived at the magic point: something weird happens between the 1272 and 1273 byte count, as the following two screen shots illustrate (click for larger versions, look at the upper right and lower left of each).

search for files <1273 bytes in size

search for files <1272 bytes in size

Logically, the second search should yield slightly fewer results, assuming there are a couple of files on the drive that are exactly 1273 bytes (in reality, there are exactly 15 1273-byte files–this should be the delta between the two searches). In fact, the second search yields more than twice as many!

I was hoping I could narrow down what was going on by searching for specific file types instead of the *.* pattern, but as soon as I did that, everything seemed to work. Interestinly, if I then went back to the *.* pattern, the 1272B search produces a correct (lower) number! However, if I then run a 1KB search I get the higher number again, and if I repeat the 1272B search I again get a higher number.

Pretty strange, huh?

In case you’re wondering:

Intel E8400

8GB DDR800

Windows Vista Ultimate, 64-bit, SP1 and all “important” updates applied

Seagate 1TB SATA at default cluster size

Return a Record for Each Date Between Two Dates in SQL Server >= 2005

Blogging this so I don’t forget it…

It used to require some fairly ugly, resource intensive hacks (cursors, temp tables, etc.) to emit an inclusive list between two data points when the source data might not include an entry for every point (for example, a calendar, where not every day contains an event). In SQL Server 2005 and above, this is trivially easy, with a Common Table Expression (CTE) and a Recursive Query. To emit one record for every date between 1/1/2008 and 1/31/2008, you do this:


WITH datecte(anydate) AS (SELECT CAST('1/1/2008' AS datetime) AS anydate
UNION ALL
SELECT anydate + 1 AS anydate
FROM datecte AS datecte_1
WHERE (anydate < CAST('2/1/2008' AS datetime) - 1))
SELECT anydate
FROM datecte AS datecte_2

If you need more than 100 days (the recursion limit is 100), add this to the end:

OPTION (MAXRECURSION 1000)

The fact that they stop recursion short at 100 by default would seem to indicate that this is an expensive procedure, but even if you’re just using this to produce a dummy table with all the dates for several years, it’s a nice shortcut.

I just tried the following query, which emits a record for every day between 1/1/2000 and 12/31/2020:


WITH datecte(anydate) AS (SELECT CAST('1/1/2000' AS datetime) AS anydate
UNION ALL
SELECT anydate + 1 AS anydate
FROM datecte AS datecte_1
WHERE (anydate < CAST('1/1/2021' AS datetime) - 1))
SELECT anydate
FROM datecte AS datecte_2
OPTION (MAXRECURSION 10000)

On my P4-641+ the script emits 7671 records in 0 (that’s zero) seconds and “spikes” the processor to all of 3%. Granted this is not a complex query, but at least we know the recursion (if it really is recursion internally, which I doubt) isn’t expensive by itself.

Vista… 64-bit… Where’s My Headroom?

Other than a couple of virtual machine beta builds, I had managed to stay out of Vista entirely until the last month or so. Since then I’ve tried to install on three machines–a client’s Dell Optiplex, which never was able to boot after install, and two home-built systems. This weekend I built a brand new system out of all Vista-logo components. It booted; Vista reported the hardware compatible; it even got a 5.8 experience index score. But I had continuous crashing of both IE and Windows Explorer. Also, on what should have been basically the fastest hardware available, the Vista with SP1 install took over 90 minutes.

I’m walking away. My current approach for my development machine is going to be Windows Server 2008 Standard 64-bit. Again I have certified components, but 64-bit in itself represents a struggle in terms of driver and application compatibility. We’ve had 64-bit CPUs in our machines for going on 5 years, and 64-bit Windows options for almost as long, and yet you still cannot run common programs and drivers in the environment–Flash, TWAIN, most VPN software, the list of things you can’t do (or do well) is astoundingly comprehensive.

We’re heading toward a very real wall here: 32-bit versions of Vista (as with other flavors of Windows) are limited to 4GB of RAM. Yet that is simply not enough for Vista plus any serious suite of applications. At the same time, 64-bit Windows still isn’t a truly viable desktop for most users. Out of necessity, I’ll compromise on many fronts–multimedia capability, peripheral compatibility, native software availability–but some of this stuff isn’t easily virtualizable, so I’m looking at the possibility of having to keep 32-bit systems around (for example for scanning, connecting to client VPNs, etc.). I’m really starting to feel hemmed in.

I guess I could take a step back here and look at it from the Mac perspective. It works because it’s broken; it’s broken because it works. That is, by forcing a switch to 64-bit Server I’m pruning the 16- and 32-bit dead wood that’s keeping me in the 4-gigabyte sandbox. Apple users long ago embraced obsolescence as a feature. Vista and 64-bit computing may (finally) force the Windows side of the PC world to wake up to this. Or maybe not. There’s a downside to the Mac example: “performance” in an absolute sense is to some extent irrelevant, and scaling up doesn’t necessarily have to be as smooth or cheap as we’re used to, as long as the chrome is shiny and doesn’t peel off too obviously.

This issue bears similarities to the current Internet Explorer 8 web standards argument–do we break the web (force IE8 standards mode, cripple billions of web pages) to move toward the Platonic ideal of standards? Do we break the PC ecosystem (Vista, 64-bit) for the hope of increased functionality and capacity in the next generation of platforms (available today, but considered unusable by the consumer)? You know it’s a tough question when even Joel Spolsky can’t tell you the answer. But generally, culturally, we’re not long-term investors, certainly not when the benefits are nebulous and far off and the pain points are obvious and immediate. As Joel argues, for web standards under IE this is a late-bound issue–they can throw the switch any time to go back to a more relaxed mode. But the issue of Vista running out of memory and 64-bit versions not being ready for prime time is a lot harder to resolve.

Dynamically Adding Option Elements to Select Objects… The Real Story

I don’t normally blog about pure code subjects, so this is going to be way too technical/boring for the general readership of this blog. However, I wasn’t able to find the definitive answer to this question after searching around with Google, so I figured I’d contribute a little. This is also a wiki-style reminder to myself the next time I need to do this.

Mostly you’ll be interested in this post if you’re trying to programmatically add options to a select list using JavaScript. Of all the ways to do this, there are a few that work and many that don’t. The catch seems to be that IE is picky about how and when the data “inside” the option tag (the visible text in the option list) is set. According to the documentation there should be any number of ways to set this–.text, .innerHTML, .innerText. Of those, the only one that seems to be broadly compatible is .text. .innerText is IE-only, so it’s right out. .innerHTML is valid across platforms, but it messes with the object model in IE6 and IE7 (and IE8 beta 1, now that I look) in such a way that if you use it, you have to add the option element to the select element before setting the .innerHTML property. See below for a breakdown of the methods, plus test code. Blogger might break this, so be sure to look at the plain test page (“view source” is going to be a lot friendlier on that page as well).

In any case, here’s the take-away when adding options to select elements:

  • Always use the .text property of the newly-created option object to set the visible text for the option.
  • As a precaution, add the new option object to the select object’s options collection before setting other properties of the option.

create option, set .value, set .text, add to options list (generally compatible)


function createSetTextAddOption(selectEl,val,displayText) {
var o = document.createElement("OPTION");
o.value = val;
o.text = displayText;
selectEl.options.add(o);
return false;
}


create option, set .value, set .innerHTML, add to options list (fails IE6, IE7, IE8-‘invalid argument’)


function createSetInnerHTMLAddOption(selectEl,val,displayText) {
var o = document.createElement("OPTION");
o.value = val;
o.innerHTML = displayText;
selectEl.options.add(o);
return false;
}


create option, add option to list, set .value, set .innerHTML (generally compatible)


function createAddOptionSetInnerHTML(selectEl,val,displayText) {
var o = document.createElement("OPTION");
o.value = val;
selectEl.options.add(o);
o.innerHTML = displayText;
return false;
}


create option, add option to list, set .value, set .text (generally compatible)


function createAddOptionSetText(selectEl,val,displayText) {
var o = document.createElement("OPTION");
o.value = val;
selectEl.options.add(o);
o.text = displayText;
return false;
}


Attempt to add new options/selects inline (option 2 and select 2 fail in IE, either silently or with the “invalid argument” error)

According to the Microsoft documentation, this shouldn’t work at all. Here’s what they say about the option.add() method:

This method can be used to add elements only after the page loads.

If the method is applied inline, a run-time error occurs.

And yet, it mostly does work, aside from the innerHTML limitation…


// generally compatible inline adds
createSetTextAddOption(document.getElementById('sel5'),'1','added value 1');
createAddOptionSetInnerHTML(document.getElementById('sel5'),'3','added value 3');
createAddOptionSetText(document.getElementById('sel5'),'4','added value 4');

addNewSelect(document.getElementById('sel5'),'1','added value 1',createSetTextAddOption);
addNewSelect(document.getElementById('sel5'),'1','added value 3',createAddOptionSetInnerHTML);
addNewSelect(document.getElementById('sel5'),'1','added value 4',createAddOptionSetText);

// these two fail in IE6, IE7, IE8
createSetInnerHTMLAddOption(document.getElementById('sel5'),'2','added value 2');
addNewSelect(document.getElementById('sel5'),'1','added value 2',createSetInnerHTMLAddOption);

Again, I encourage you to view the plain test page to avoid any Blogger-induced weirdness.

Why I Continue to Hate Surveys

Following up on my earlier post regarding the evils of polling… MSN has an article that purports to uncover the “bottom 10” worst customer service companies. If you take the list at face value, the only conclusion you can draw is that large banks and large phone and Internet companies have poor customer service. No initial surprises there. But the fact that I’m at least a part-time customer of up to seven of these companies–and that only one has stood out in my mind as having truly bad service (Time Warner)–set off some warning bells. Do they seem particularly bad at customer service simply because they have so many customers to complain about bad customer service?

If you dig into the methodology of the survey, you’ll find it’s a little more complicated than a straight ranking, and that in fact there’s no “top 10” to go with the bottom 10. Here’s why:

Right off the bat you have a self-selection bias inherent in asking the initial group only for bad customer service experiences and then picking the top 20. If you asked the same group for their best customer service experiences you’d likely get a substantially similar group, simply because so many people are customers of these same 20 companies.

Zogby tried to clean it up a bit by offering a full scale of response (“excellent,” “good,” “fair,” “poor,” “not familiar,” “not sure”), but the damage is already done. In fact, by discarding the “not sure”s and “not familiar”s they actually increased the bias against large companies. This sort of downward divination can only serve to exaggerate the response biases in both groups. So this survey ends up telling you very little about what to expect when dealing with these companies, and it gives you no positive information at all, since no data was collected about good customer service experiences.

Bottom line: Even a company with years of experience applying science to customer satisfaction research can find it challenging to come up with a robust methodology. And that’s presumably without the influence of the tabloid-style inflammatory agenda that MSN has.

Google Gets Into the Vaporware Business

I guess you know it’s a mature technology company when it starts releasing phantom products. Google announced (pre-announced?) new hosted software for presentations. But since when does Google announce things without anything to showcase? Shouldn’t they have been in beta for a year or so first? Shouldn’t I have an account before they announce it to the world?

Though they say it’s not a PowerPoint competitor, I’ve been waiting for this shoe to drop at least since the acquisition of Writely. (I’ve also argued that Google search already outperforms PowerPoint when it comes to making an actual, honest point in a transparent business world, but that’s a more philosophical debate.)

It’s interesting that Google’s explanation for why their soon-to-be-comprehensive “office” collaboration platform is not a direct Microsoft Office competitor is “It doesn’t have all the functionality, nor is it intended to have the functionality of products like Microsoft Office.” That’s at best a backhanded compliment, since one of the perceived problems with Office is the creeping featurism and overall complexity (not to mention being backed by byzantine technologies like Exchange Server that are prone to blowing up in the faces of small businesses). Many have argued that 80% of users could (and sometimes do) get by with 20% of the functionality of Microsoft Office, with improved productivity due to reduced complexity, and this would seem to be the territory Google’s hosted workspace is prepared to inhabit.

By the way, if you want to sniff the vapor a little more deeply, poke around the Google cache or Internet Archive of Tonic Systems original web site. Tonic is the recent Google acquistion rumored to be tasked with making gPresentations fly. It looks like they already had a pretty dense Java-based toolkit for manipulating PowerPoint presentations.

Microsoft: We Got Your .NET… Right Here

Or maybe we don’t. I just read that GotDotNet is going away. This is not that shocking, since the site has seemed sort of half-assed from the beginning. However, I will say that I’ve had projects that literally could not have been accomplished without GotDotNet’s help (and that of its contributors). In particular, GotDotNet was the de facto home of Stephan Gossner’s Microsoft Content Management Server code samples (that link will die soon). Of course MCMS is an end-of-life product at this point, but man there’s a lot of neat code on this site that’s suddenly going to be a lot harder to track down.

Some, but certainly not all, of this material is duplicated on various newsgroups. But often those posts link back to GotDotNet for code samples. So even if they do somehow relocate this content–at the moment there’s no stated plan to even do that–all of those links are likely hosed.

I understand Microsoft’s dilemma here, though I don’t particularly buy the “reinvest the resources currently used for GotDotNet” line. On the one hand, from a branding perspective, they can’t have this half-assed thing rusting out there in the ether with their name on it. On the other hand, they really need to keep their foot in the door in terms of community web sites, especially for developers. In terms of “resources” they want to reinvest, they can only mean people, and I’m not sure who they’re worried about (since the “Team” page is already dead), but it seems like some Microsoft people actually found this site useful.

They’re not offering any kind of plan for this phase out (they’re not even calling it a “transition”)–just a laundry list of other Microsoft developer sites. They’re chopping this thing off like a gangrenous limb. Maybe they’re assuming Google will take up the slack.

Microsoft’s New Strategy: Ray Ozzie… Everywhere!

I know he never really went away, but sometimes I think they woke Ray Ozzie up from cryogenic stasis in 2006 (June 15, to be exact). Since March 1, it has seemed like all Ozzie, all the time–like they released his new version simultaneously with Vista. Next up, Ozzie07 keynoting Mix07.

By the way, if anyone from Microsoft is listening, I’d still enjoy free tickets to Mix. This year, more than ever, you really owe it to me. Especially after sucking me in to that execrable Office 2007 launch. Did you notice that fully half the developer track walked out at the midpoint? You know what the free copy of Office 2007 did for me? Got me to download OpenOffice.org. You gave me a free copy of your premier application suite and I can’t even stand to install it. So yeah, if you’re “courting developers” so hard (and you need to–we’re the last truly discretionary users of your products), you ought to court me–because right now I’m finding it a lot easier to say “LAMP” than “WISA.”

Oh, and send me one of those sweet laptops while you’re at it. My journa-blog-listic ethics won’t be offended.