Showing posts from 2012

Updating Paypal IPN PHP 4.1 scripts to use HTTP 1.1: SOLVED!

Paypal has made a change in their system which required some changes to my long-working PHP code, version 4.1. Here's the official notice:

Action Required before February 1, 2013
Merchants need to update their IPN and/or PDT scripts to use HTTP 1.1, and include the "Host:" and "Connection: close" HTTP headers in the IPN and PDT scripts.

Their full-sized example script is now for PHP 5.x so it wasn't easy to see how to make the changes to my older 4.1 script. Yes, they give you a four line snippet showing the new code added, but without enough context to make it work. There's several other forum posts out there suggesting that I'm not the only one confused. None of them have the complete working code posted, though. So here's the correct solution (tested and working as of today):

 // post back to PayPal system to validate
// OLD working version
//$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
//$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
//$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

// new working version:
$header .="POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .="Host:\r\n";
$header .="Content-Type: application/x-www-form-urlencoded\r\n";
$header .="Connection: close\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

// new working version changes finished, old code resumes:
$fp = fsockopen ('ssl://', 443, $errno, $errstr, 30);

One thing that tripped me up: the header needs to end with the double end-line, so the order matters at least in that one way. I'm not sure the rest of the order really matters, buy hey, this works!

Note: this code is part of a larger package that delivers software (or anything zipped) via email to people who send you money with PayPal (or Amazon). Check it out:

EVGA GTX 260 - the best driver choice under WinXP?

I recently upgraded to a used GTX 260 (EVGA, type SC; model 896-P3-1257-AR to be specific), for the purposes of playing Minecraft, etc. more smoothly. This has been pretty successful - the GTX 260 gets about 2x the frame rate of my old ATI X800 XL, and is only slightly more noisy (because the fan is larger and runs faster). 

But the upgrade was not without problems (since solved, see below). The moment I put the card in I started having problems with hibernating WinXP which had never occurred with the old video card.  About 1/4th of the time hibernation would appear to finish, and the screen would go blank, but the machine would not actually switch off. Worse, upon rebooting, the computer would act like it had hung, and discard the hibernation file, instead proceeding to a regular, full boot. It was like my computer was crashing about once a day. 

Suspecting a driver incompatibility, I tried several different ones:

301.42 - hibernate problems
296.10 - hibernate problems
285.58 - machine somewhat unstable
280.26 - machine very unstable 

275.33 - hibernate OK, but machine is now unstable (most often hanging hard while watching video).

Other recommendations from around the net:

EVGA forum.

I contacted EVGA support, and they gave me a bunch of fairly basic tech support suggestions that I had little hope would fix the problem, and indeed they didn't. Then they suggested I RMA the card, which I did. Problem solved! The card is now completely stable with out any hibernate problems under the 301.42 driver (I didn't test any others). It only cost me about $5 to RMA the card, because of shipping it back to them. Turn around was super fast - they sent the replacement card out the same day it got to them, and it was in my hands the next day (note, however, both EVGA and I are in S. California).

So to conclude: hardware problem.

Update, again:  after about 1 month I had another crash on entering hibernate. That's a lot less than before I sent the card back, but still suggests that the problem isn't actually fixed, as my machine never had this problem with the old ATI card. Not sure what to conclude now.

How much faster have CPUs gotten in the last 15 years?

If you got into the PC business in the 80s or 90s, you can probably remember how each new CPU from Intel was a pretty big performance boost. In those days, a new CPU could offer two kinds of performance advances: clock speed increases, and instructions that took fewer clock cycles to complete. By the time the 486 came out, most instructions took just 1 cycle to complete (down from 4-6), and we had gone from 8mhz to 100+mhz in just a decade. With the first Pentium, Intel introduced the ability to complete instructions in parallel, which meant that a single clock cycle could sometimes result in 2 instructions executed (or more properly, completed, since at this point we had execution pipelines). Later CPUs had even more pipelines, but the gains were diminishing. Clock speeds were still increasing, however. This did not mean that CPUs were getting faster though. Famously, Intel actually took a big step back in performance per clock cycle from the Pentium 3 to the Pentium 4, in order to push into the 4 Ghz range.  In modern times, performance per clock cycle has taken a bit of a back seat to putting more cores into your CPU - great if your software supports multithreading, but even after almost a decade of this approach, a lot of software does not.

So, how do CPUs of the last 15 years compare on single-threaded computation? Not many people have the CPU collection to answer this question, myself included. Tom's CPU charts is the closest I could find, but in 2006 they switched to using a multi-threaded mp3 benchmark, so the best they can offer is the years 1994-2004. To extend this I replicated their benchmark (single threaded) on my desktop, which is shown at the bottom of the following list.

Tom's cpu charts 2004 (seconds to encode a large MP3 file using LAME, so smaller is better):

1994 Intel Pentium                      100mhz     4361
1997 Intel Pentium MMX           233mhz     1926
1999 Intel Pentium III                 600mhz       360
2000 AMD Athlon thunderbird  1ghz             233
2001 AMD Athlon XP 1500+   1.3ghz)         169
2001 Intel Pentium 4                  1.8 ghz         162   
2004 AMD Athlon 64 2800+    1.8ghz          119
2003 AMD Athlon XP 2800+   2 ghz            105
2004 Intel Pentium 4 570           3.8ghz            84
2004 AMD Athlon 64 FX-55    2.6ghz            82
2010 AMD Phenom II 255 X2  3.1ghz            46 (estimated)

The most impressive gains happened in the 90s - 4300 seconds is a long time to encode an MP3 (even a long one). Since then, single threaded performance has gone up, but not so much. The difference between 82 seconds and 46 is almost half, but that's not such a huge change in how long you have to wait. We can see, however, a general trend that more is getting done per clock tick (excepting the P4, of course). 

The weakness of this list, of course, is that there is no attempt to make sure that each of these CPUs is comparable in terms of cost to the user when they were introduced. But it does show that while raw Ghz hasn't gone up much in the last decade, compared to the 90s, single thread performance has still continued to rise somewhat faster than Ghz. 

Radeon incompatibility with Dell LCDs (U2410)

I recently upgraded my video card to an EVGA 260 GTX (SC), for reasons of performance and compatibility. My old video card (Radeon X800 XL) was reasonably quite, fast enough for non-gaming needs, and OK for watching flash video, but not great. Most annoying of all, it has an incompatibility with my Dell U2410 LCD, where it cannot wake the screen back up after it has been put into power saving mode by the screensaver. Apparently the video card sends a signal to the DVI port to see if there is a device there, and the DELL takes too long to respond so the ATI card stops sending a signal, and never discovers that anything is attached. I found I could get around this by opening a full-screen DOS prompt, which causes the ATI drivers to power up the DVI port whether it thinks there is a screen attached or not. I set up a hotkey to open and then close a fullscreen DOS window, thus bringing my display back to life, but what a pain! I don't think this was a problem with all Dell displays - I don't recall the same problem with my older 2408WFP.

To be fair to ATI, this is an old card. But the drivers weren't that old; you'd think this was something that could have been fixed in software. The good news was that the upgrade to an Nvidia card fixed it. Plus, flash video no longer exhibits taring problems. You know, full screen video playback was a problem most software solved in the late 90s. Flash is such a dog - apparently it can only use hardware acceleration with fairly modern video cards - which the ATI card certainly isn't. But then every other video playback program I used was tare-free, so it certainly had the horsepower to do the job if given even half a chance.

VMWare player 4.0.1 review

I just started playing with VMWare player 4.0.1, which was released in Nov 2011. It's pretty slick, and based on some lightweight benchmarks, computational performance loss turns out to be minimal. GUI performance is also quite good, and I conclude that using a VM to try out software or otherwise firewall your main machine from risky activities is a great idea with little downside.

Program installation was easy. VMWare requests that you create an account and give them an email before you can download. I found, however, that they do not check if the email is valid before letting you download the install image. Installation does leave a few VMware services running all the time, even if you are not running the player at all, but it's only about 15MB of overhead, so all in all it's tolerable, though I don't see why they can't just run those apps as needed.

OS installation was even easier. For supported OSes (I used winxp sp3) it knows how to automatically install the OS without any interaction from you. Just enter your license key, specify a few parameters (disk size, etc), and the rest of the install is completely unattended. Very nice for getting a good clean install of Windows for testing purposes, etc.

Overall performance seems very good. I tried a synthetic cpu benchmark (Google's v8 javascript benchmark, version 6, on chrome 16.0.912.75 m), and found that the performance was somewhat variable, ranging from 83% to 90% of the benchmark result when run outside of the VM (that is, a 10-17% slowdown). This was on an AMD 255 CPU (X2, 3.1ghz). I doubt I'll ever notice. Visually, performance also seemed snappy for GUI interactions. I tried bubblemark, a simple javascript/dhtml benchmark, and found unbelievably good performance ( both inside and outside the VM, performance was the same, at 200-210FPS.  Finally, I tried futuremark's peacekeeper browser benchmark. Visual performance was also good, with HTML canvas being only 1fps slower on the VM, at 28fps, however the rendersuite (dynamic updates of table colors) was slower, at 45fps (vs 75). No info on why these would be so different, but I'm guessing that table updates are for no good reason more CPU taxing. Or something.

So to conclude, performance is very good - more than enough to use for all types of web browsing, and even compute-bound tasks. Though I did not test outside of Chome, I see little reason to think native apps would be distinctly different, though it is reasonable to wonder if GUI acceleration might be better outside the VM when using native (win32/.net) apps. Another test worth running would be 3d performance, should you want to run games in the VM. And, of course, it would be worth comparing all this to OpenBox, the other free VM out there. But with performance so good in VMware Player, I can't work up the motivation!

Finally, what are the resources consumed? Disk space is roughly one-to-one with the VM, since the disk image itself expands as you use more of the allocated space. There is also overhead for RAM hibernation, etc, but nothing very surprising. A bare install of XP + chrome took just under 4gb. RAM use is about 256MB above what you allocate to the VM (ie about 768MB on the host OS for 512MB given over to the VM).

Postscript: I did not try out the VM 2 HOST connectivity (shared files, clipboard, etc). It sounds like these are well supported, from what little I've read though.

Email me


Email *

Message *