Shareware Beach

Wednesday, 26 October 2005

A New Era of Computing

Filed under: Software Development — Jan @ 10:31

With the limited release of the EditPad Pro 6 beta, JGsoft has entered a new era of computing. Previously, all our products were designed for computers with a single processing core (CPU). Almost all present Windows applications and utilities fall into this category, because multi-processor systems used to be very expensive. Putting multiple CPUs into a single computer only made–and still makes–sense for high-end workstations and servers.

The new PC I got a few months ago has a Pentium 820 CPU. I got this system because it was the cheapest dual-core system locally available at the time. In fact, the Pentium 820 was cheaper than Intel’s fastest single-core Pentiums.

Soon, run-of-the-mill computers and even notebooks will come equipped with multi-core CPUs. Intel has announced quad-core server CPUs for 2006, and quad-core mainstream CPUs for 2007. If Moore’s law continues to hold true–the number of transistors that can be put cost-effectively into a single CPU doubles every 18 months–we’ll likely see the number of CPU cores increase further in the future.

The significance of this is not that we’ll have faster computers. In fact, when running the applications I have, my 2.8 GHz Pentium 820 isn’t much faster than the 2.4 GHz Pentium 4 I bought three years ago. The reason is that applications designed with a single active thread in mind don’t take advantage of the extra CPU core.

I’ve made a screen recording of EditPad Pro 5 opening a huge file. The example is somewhat artificial, since few people put a million lines of source code into a single file. But it makes the situation easier to observe in the Windows Task Manager. As you’ll see in the movie, EditPad Pro 5 “goes stupid” the whole time while it scans the file for line breaks and applies syntax coloring. All the while, CPU usage is pegged at 50%. Both cores share the load, but it’s only 50% since there’s only one active thread. The other running threads–the Windows Task Manager and other OS threads–don’t use any measurable amount of CPU time. But they do cause EditPad Pro’s thread to be switched between the cores.

The significance of affordable multi-core systems is that consumers will become increasingly intolerant of applications that “go stupid”. Particularly when that application isn’t using 100% CPU time. An application can always use one CPU core for foreground GUI handling, while lengthy operations run in the background.

EditPad Pro 6 will use up to 4 threads. The main thread handles all GUI and editing tasks, while 3 background threads take care of finding line breaks and word wrapping, applying syntax coloring, and building the file navigation tree.

Even this modest amount of threading makes a dramatic difference. As you can see in the recording of EditPad Pro 6 opening a huge file. The file appears instantly, complete with syntax coloring. The only time you’d have to wait is when you want to jump to the end of the file and EditPad Pro 6 hasn’t finished scanning for line breaks yet. If syntax coloring isn’t done yet, the end of the file is simply displayed without. (Since Pascal supports multi-line comments, the whole file has to be colored.) The movie clearly shows that the line break scanning and syntax coloring threads each tie up one CPU core. The foreground thread doesn’t use much CPU, since I’m simply scrolling through the file.

Making your application multi-threaded isn’t enough. My first attempt at separating line break scanning into its own thread worked wonderfully on a single core CPU. But on a dual core system, CPU usage was still pegged at 50% while scrolling and line break scanning at the same time. The reason is that while my benchmark app had two threads, they weren’t running simultaneously.

Whenever the foreground thread had to repaint the screen, it would block the line scanning thread completely. Doing that is fine on a single core computer, but kills performance on a multi core system. The final solution uses critical sections to only block either thread for the smallest amount of time when line break information is updated.

In the end, what matters is percieved speed. How many seconds of CPU time your app clocks up in the task manager doesn’t matter. How many seconds your customers spend waiting for your software is what it’s all about. The ideal is obviously not to make them wait at all.

In EditPad Pro 5, performance of the syntax coloring mechanism was vital. If it was slow, users would spend time waiting for it. Therefore, EditPad Pro 5 came with a lot of built-in coloring schemes for various popular file formats and programming languages. I coded these schemes directly into the Delphi source code, so they’d run as fast as possible. By contrast, user-contributed schemes used a system based on regular expressions, which precluded many of the assumptions and optimizations the built-in schemes could make. It also made it impossible for users to customize the built-in schemes other than choosing the color palette.

In EditPad Pro 6, syntax coloring performance is irrelevant, as long as it’s reasonable. If a scheme is too complex or a file too large for the syntax coloring to keep up, it’ll simply temporarily disappear until it’s done. As a result, all syntax coloring schemes included with EditPad Pro 6 now use the regex-based custom scheme system, making them flexible and easy to customize. Though EditPad Pro 6 needs significantly more CPU time for syntax coloring, it feels much faster since you don’t have to wait for it, and it’s still fast enough to keep up while you’re scrolling. Only quickly hitting Ctrl+End on a large file or using a rediculously complicated scheme (some user love ‘em) might make it disappear for a while.

When benchmarking your application, think about human time rather than CPU time, and parallellize those tasks that users shouldn’t have to wait for.

Tuesday, 11 October 2005

Delphi 2006 and Beyond

Filed under: Software Development — Jan @ 18:34

Borland has announced Delphi 2006. The most significant difference with the 2005 version will be that C++Builder is now part of the package, integrated into a single IDE with Delphi (Win32 and .NET) and C#. All editions of Delphi include all 4 language platforms.

Also new is that the Professional and Enterprise editions will now contain key parts of ECO, Borland’s Enterprice Core Objects modelling framework for Delphi for .NET and C#. Previously, ECO was only available in the expensive Architect edition. ECO looks like it should make database development a lot easier, by automatically generating Delphi or C# code based on the models you create.

The Delphi roadmap also looks promising, with a VCL version for Avalon (or whatever Microsoft calls it now) and native 64-bit Delphi and C++ compilers announced for 2007. Though some may claim that’s royally late, it seems right on time for me. I prefer that Borland take their time to get things right, rather than rushing an unfinished product to marked like happened with Delphi 2005. By 2007/2008, enough of our customers should have 64-bit systems to make the effort worthwhile. Don’t forget that while 64-bit hardware is common, 64-bit operating systems are not.

My new PC has a 64-bit CPU. Windows XP x64 runs just fine on it. The motherboard included 64-bit drivers for everything, and Windows automatically installed a Microsoft driver for the GeForce 6600 graphics card. The problem is external hardware. According to Canon’s web site, my old S820 printer will never be supported on x64. Drivers for the new MP780 all-in-one I bought are “coming soon”. Since I don’t have any 64-bit software, it doesn’t really matter. 32-bit applications get no benefit from a 64-bit OS.

The result is that I’m still using my trusty Windows 2000 installation, and will continue to do so until Vista arrives. At least it is good to know that all JGsoft products run just fine on XP x64.

Friday, 9 September 2005

Back in Action II

Filed under: Personal — Jan @ 12:11

I was back in action, but it didn’t last long. Soon after I had put the new system together, the hard disk started acting up. I had reused all the drives from my previous system. Since I don’t like taking chances with my data, I went out to buy a new disk, a nice 250GB SATA drive.

Unfortunately, getting the system up and running with the new drive took way longer than I expected. I freshly installed Windows XP (which I use as a scratchpad for beta testing etc.), and restored my Windows 2000 development partition from a backup. All that went quite well.

Trouble began when I started copying over all my stuff onto the data partition, now a whopping 160GB with 30GB of stuff on it. Windows 2000 seemed to copy and read back all the data just fine, but when I rebooted in XP, it would tell me the data partition needed a disk check, and proceed to find thousands of errors. XP seemed to fix the errors just fine. But every time I touched the disk with Windows 2000, XP would act up, but not the other way around.

So I figured my Windows 2000 SP3 installation couldn’t deal with the huge hard disk, even though it didn’t give me any error messages. Trying to locate a solution using Google proved to be very frustrating. Looking for issues with large hard disks got me lots of sites trying to sell me a new disk. Looking for Windows 2000 SP4 and NTFS got me lots of information about Windows NT 4.0 SP4 issues with NTFS. (I was reluctant to install SP4, since I previously ran into some troubles installing SP4 on another system.)

Finally, I thought maybe reinstalling Windows 2000 on top of the existing installation would make it properly detect my new large hard disk. While scanning the disk, the setup mentioned my disk was 131070 in size. So I googled for “131070 MB Windows 2000″, and immediately found a newsgroup discussion pointing to the fix: I needed to add one stupid registry value. So I did, and now I’m back in action!

Don’t ask me why Windows 2000 SP3, which supports hard disk larger than 131070 MB just fine (unlike SP2 and earlier), needs a registry item to actually enable that support. I bet few people buy a big hard disk to use only part of it.

Wednesday, 7 September 2005

European Shareware Conference Reservations Made

Filed under: Conferences — Jan @ 10:25

I just finished making my reservations to attend the 5th annual European Shareware Conference. This year it will be held in Brussels as decided by popular vote.

As usual, it was a bit of a quest finding good prices for the plane and the hotel. KLM’s website, however, makes it very easy to get the best price (as long as you’re flying KLM, of course). After selecting departure and arrival cities, you’ll get two calendars for the departure and arrival dates. The calendars are color-coded to indicate the lowest booking class available. Light blue means you can get the cheapest, restricted ticket, while dark blue means only full price tickets are available for that date. When you click on one of the dates, a bit of Javascript instantly fetches the new price. This makes comparing prices so much more convenient than on most airline web sites, where you have to resubmit the whole request to see the price on another day.

That doesn’t mean that all dates with the same color have the same price. Weekends are more expensive than weekdays, at least on the Bangkok-Amsterdam route. Since I’m combining the conference with a family visit, I can be quite flexible with the dates that I fly.

What really surprised me is that if I opt to fly Bangkok-Amsterdam-Antwerpen (last leg by train), the calendar turns almost completely light blue for November. But if I choose Bangkok-Amsterdam only, most days are darker. Consequently, on many days (but not all), the total price including the train ticket is actually lower than without. I guess the train makes me a transit passenger, and KLM wants to sell more tickets to transit passengers. Still, they’ve effectively priced their train tickets negatively during most of November. No wonder airlines around the world are having a hard time staying profitable.

The conference will be held in the Sofitel Astoria Hotel. I always prefer to get a room in the conference hotel, since that’s where the action is. You’ll save a few euros staying in a cheaper hotel nearby, but you’re likely to miss out on the socializing, or having to brave the weather to meet everyone.

If you’re sure you’ll attend the conference, you can save some euros by making your reservations directly with the hotel on their web site. The ESWC has negotiated a single room rate of 135 euro, and a double room rate of 155 euro, including breakfast. This is a better price than the “best unrestricted rate” on the Internet, which excludes breakfast. If purchased separately, breakfast is a rediculous 25 euro per person.

However, if you book your room before everybody else does, you can probably get one of the better rates on the Internet. The “Sofitel Getaway” promotion for 3 nights is 340 euro (single) or 370 euro (double), including breakfast, or a savings of about 100 euro compared with the ESWC rate. It requires a non-refundable one night deposit, though. And it’ll probably run out way sooner than the October 25 deadline for the ESWC rate.

If you don’t want breakfast, there’s also a “hot deal” which must be prepaid in full. Compared with the Getaway promotion, the breakfast seems to have been calculated around 10 euro per meal, which is far more reasonable than the 25 euro rate.

Anyway, you can find me in or around the Astoria hotel from Friday 4 November till Monday 7 November.

« Previous PageNext Page »