Raymond Chen Blog’s new exciting article
Raymond Chen’s blog has another exciting^H^H^H^H^H^H^H^H boring elitarian article on how poor Microsoft is forced on bad choices because of third party software using undocumented functions/resources.
Fact is, Windows has the crappiest versioning convention ever (that is : none). Fact is Microsoft software is free to use undocumented stuff and has not licensing issues (for example for copying resources). Fact is Microsoft software has of course priviledge of compatibility testing and hacks.
Really you can write so many articles on how third party applications break on Operative System modifications before you become insulting to third party developers who have to use any available resource to compensate for the lack good APIs in the OS.
I won’t even go to mention how .net windows forms lack any kind of user controls from the last 10 years. The most advanced controls in .net framework are the common controls of windows 95. There isn’t even support for icons on menus. I will come back to Raymond’s block in 2009, when he will complain in his blog (which will be titled “not actually a win64 blog”) about how fucktard were those applications which did whatever to have icons on menus or tab pages of the right color under xp themes. Someone will mention how bugged was Application.EnableVisualStyles() at he will digress on why even EnableVisualStyles was written that (bugged) way to keep compatibility with god-knows-what.
And if System.Windows.Forms has this problems, I don’t even want to check out MFC.
BTW I removed Raymond’s blog from the list of links, because it conflicted with some important third party software I’m not going to mention for legal issues.
—
Edit : the reason I removed RC link is not because I don’t link a blog anymore when it posts a message I don’t like. Almost all the links in my page have posts I don’t like but they are still there. The fact is I don’t want to be associated with such elitism and Only-Microsoft-Does-It-Right (when most proofs are for the opposite!) zealotry.
Unbelievable Optimization X
This is something which happened some years ago.
There was some-project I won’t name(*) (let’s just say it was a server emulator of some popular MMORPG), with their development forum. I found a post suggesting an optimization they were going to implement. Basically the file saving phase was something like this :
if (someplayer->hp != 0) fprintf(fout, "hp=%d", someplayer->hp);
if (someplayer->something != 0) fprintf(fout, "hp=%d", someplayer->something );
if (someplayer->foobar != 0) fprintf(fout, "hp=%d", someplayer->foobar );
if (someplayer->purplet != 0) fprintf(fout, "hp=%d", someplayer->purplet );
if (someplayer->dontknow != 0) fprintf(fout, "hp=%d", someplayer->dontknow );
Of course, most attributes were defaulting at 0 (or the value was different in the if — whatever) and many I/O operations were saved (also file length was greatly reduced due to this “optimization”). The reason of this high effectiveness was that most attributes were not used unless in a particular condition, and so most of the time they had a default value.
Comes the Pentium 4 and its light-years long pipeline.
Developers forums started writing about how crappy was the new architecture (the P4 debuted at 1.5GHz - at that speed it was slower than a P3 1GHz, not to mention the Athlon - the real power of the P4 was revealed only when it debuted a new revision and frequencies of 2.0GHz and above) and how much a single conditional jump could stall the pipeline and lose tiny precious clock cycles.
Then the idea struck a developer of that project. What if we remove all the if conditions ? No more conditional jumps yippieee!
This is the kind of ideas you feel dumber only hearing it. Ok, so you pull out the ifs and suddenly you have about double the number of fprintf. Since there is file caching (so that not particular much time is lost waiting for the disk I/O) the performances should be higher, right ? Wrong.
And the reason is simple. A single fprintf may be something like hundreds of conditional jumps. Really. (Not to mention the additional load in terms of disk I/O which whatever superscsi you have, it’s slower than the slowest of the P4s)
Let’s analyze (lightly) what happens on a call to fprintf. After all the arguments are pushed on the stack, the procedure is called. Here the format string is parsed to find the % sign. There is comparison/conditional jump for every character, but we can be sure that most of this conditionals are correctly predicted and only a fraction of them are mispredicted (probably the ones where the % is found). After the % char is found, a quite complex loop (thus involving a number of conditional jumps) parses the input string. For %d tokens this loop ends quite quickly but for more complex tokens this can be quite expensive. In the meantime, parsed characters were being passed to the file buffers, ready to be written out (we’ll see later what this means). When the %something token is parsed, the argument is written out to the disk. This involves things like sign extension and stuff like that and no, most of it (in Visual C++ RTL at least) is not done using movsx and alikes, but with slow C code using various if, to mantain compatibility across platforms (the VC++ RTL should run on x86, x86/64, IA64, Alpha, Mips and PowerPC, even if the support for most of the listed architectures is now dropped) . After this a number should be converted from the internal representation to the decimal one, and this involves a bazillion of jumps and divisions by 10 (in M$ Visual C++ you can see all this code in the crt/src/output.c file). After the string is prepared it’s stored in the files buffers. Overflows checks must be made (more jumps! and memory copies, with an high chance of trashing what is in L1 cache if not even L2) and when they are emptied (and sooner or later they will be) controls goes to ring-0 code. Apart from the jumps, going to ring-0 is an uber-slow operation in itself. Also ring-0 code has quite an high chance of accessing a resource which needs a synchronization lock with an high chance of a spinlock loop or, worse, an anticipated task switch.
But boy, you saved a conditional jump.
(*) There is a secret hint hidden in the post about the identity of this project…
Edit : I wrote Pentium 4 1.5MHz :D. While it would be funny to check if the P4 1.5MHz could beat the 8086 at 4.77MHz or the 286 at 8-12Mhz, usually Pentium 4 users runs them slightly faster ![]()
YaSudoku 0.2
In the past days there were a couple of requests for an update to YaSudoku (the ability to manually input a problem for later solving) and for a new proof of concept of DEP by passing.
I’ve done only one of the updates, guess which from the title
You can download the YaSudoku update from here
ITP .. and I’m not dead!
Ok, so it’s quite some time since my last post.. but I’m only overloaded with things to do, this blog will be filled soon with some more material.
Then, I’ve spent some time browsing wikipedia. I’ve read quite a number of stories/facts about mathematical and philosophical paradoxes (on which I’ve even done a minor contribution), the story of the mythical NexGen (my favourite CPU firm ever) and a few other minor topics.
Browsing I’ve found that ITP (the Italian Translation Project) is still alive! Only 7 months ago I was searching them on the internet and I was unable to find them. They are voluntary guys who have translated quite a few role playing games in Italian, most notably Planescape:Torment and Morrowind. A well known fact (between my friends) is that PS:T and Morrowind are 2 of the 5 games I liked more ever (I can’t decide which one I like the most, the other three are Daggerfall, Day of the Tentacle (*) and Eye of the Beholder (*)).
(*) Purplet is the contraction of Purple Tentacle, the evil monster from Day of the Tentacle. Xanathar, another nickname I use often, is the evil monster from Eye of the Beholder
ITALIAN VERSION :
Quest articolo viene ritrascritto anche in italiano, essendo riferito a un progetto tutto italiano. Browsando wikipedia ho scoperto che l’ITP (Italian Translation Project) è ancora vivo e vegeto
Per chi non lo sapesse (ovvero la maggior parte delle persone al mondo a parte pochi malati di mente quali il sottoscritto) ITP è un team che ha prodotto delle traduzioni volontarie di alcuni giochi (principalmente GDR) in inglese. Si tratta di giochi del calibro di Planescape:Torment e Morrowind (ovvero due dei miei 5 giochi preferiti assieme a Eye of the Beholder, Day of the Tentacle e Daggerfall) in cui il testo riveste un’importanza fondamentale (specialmente in PS:T).
Tra parentesi, consiglio a chiunque non l’avesse fatto di giocare PS:T con la traduzione italiana. L’unico difetto di PS:T è che prima o poi finisce. [Se siete dei trigger-happy che passano le giornate divertendosi a trivellare mostri a Doom 3.. NON installate PS:T. Non vi piacerà.]