This is really odd. I opened a five-meg text file in Notepad, did a
search and replace, and Notepad locked up. Assuming it was just taking
its time with a job as large as I gave it, I went to do other things...

....and found the whole XP system in an abnormal state. It was not
sluggish, per se -- instead, a lot of things were in a broken state.
Menus wouldn't drop down. Windows wouldn't close, move, or resize.
Scrollbars wouldn't work. Lots of things *would* work, but lots of other
things wouldn't. All applications affected -- web browser, another
Notepad I tried opening, other things. Menus sometimes start working,
then stop again. Most things stop working for a while if I switch tasks,
then work again spontaneously a bit later.

Task Manager (which is affected itself, making it difficult to use)
shows Notepad using 50% CPU and around 12 megs of memory. As far as I
can tell, that leaves 50% CPU for the rest of the system and gobs of
physical memory free, so it's not CPU starvation or thrashing that's
making things wonky.

Which means that Microsoft has a serious bug somewhere. Windows XP is a
protected-mode OS. No single application is supposed to be able to cause
systemwide havoc, save perhaps by hogging memory or CPU. This Notepad is
doing neither, relative to what's available, yet it's somehow brought
the whole system to its knees.

In fact they must have two bugs. One in Notepad that it would do this in
the first place, and one in the Windows kernel that it would let Notepad
wedge parts of the entire system without it even having to saturate the
CPU and memory.

The Notepad is still wedged, so I guess it's not merely slow. It's now
been forty-five minutes since I told it to do the search and replace.
Even doing this to five whole megs of text shouldn't take this long, not
with it using half of the 2GHz CPU in this machine. As near as I can
figure it, that means Notepad has been running at 1GHz by itself, and in
ten minutes has performed 600 billion calculations. To do a global
search and replace over a text file of length N requires about N runs
through some short character-comparison and counter-incrementing loop,
times the loop's length, plus in the stupidest possible implementation a
copy of the entire remainder of the file from each replace onward. In
this case, that's (generously) five hundred million or so CPU
instructions plus any copying. Copying is going to use a number of
instructions comparable to the portion of the file past the replace,
times a single-digit number, if it has to copy each character one at a
time instead of using mass-move instructions of some sort, i.e. if it's
implemented stupidly.

Assuming 60-character lines or so in a five meg file, that's about
80,000 copies *if* there's an average of one occurrence of the phrase to
replace *every* line. The average amount to copy in this case is half
the file, or two and a half million characters, or (say) twenty million
instructions. Times 80,000 is 1.6 trillion or so.

The *only* way to get more than 600 billion instructions is if Notepad
uses the poorest possible choices of algorithm, eschews mass-move
instructions or data structures more sensible than a 5 meg array of
characters for a document that large, AND there are that many
occurrences of the replace target.

And even then, it will take this machine and Notepad using 50% CPU less
than half an hour to do it.

We're coming up on the fifty minute mark now...

Obviously, it either uses unbelievably boneheaded algorithms, such that
they had to actually go out of their way to make it slow instead of
merely using the most naive programming possible, or else it's wedged.
Dead as a doornail.

That half the rest of the system is acting strange despite having plenty
of memory and CPU left over is another strong indication that Notepad
isn't merely being slow, but has managed to gum up the works in some
critical part of the operating system somehow, and therefore has
probably gummed up its own works at least as severely and will never
finish its job.

Which means it's time for me to end-task that Notepad, maybe reboot
after, and then go find a corner to go sulk in and cry, because it looks
like Windows does not provide ANY possible way for a user to do a large
global search and replace on a longish text file, and therefore there's
no way for me to continue with my larger task, and it's the end for me.