Poker Copilot and CPU usage

In recent years, operating systems such as OS X have made it easy to monitor a file, folder, or set of files and folders for filesystem changes. This means a program like Poker Copilot uses fewer operating system resources (such as CPU) to find whether you’ve got a new hand history file in one of your hand history folders, or whether a hand history file has had a new hand added. It also makes the programming code dramatically simpler. Simpler code is less error-prone and easier to maintain.

I’ve tried twice to add file system monitoring to Poker Copilot. The first time was in the early days of Poker Copilot, in version 1, I think. It didn’t work because Full Tit Poker seems to keep a hand history file open all the time, rather than opening the file, adding a hand history, and closing it. Unfortunately OS X’s file monitor libraries don’t inform of the change until the file is closed. At least, this is my understanding of why the file monitor library works with PokerStars but not with Full Tilt Poker. 

The second time I attempted to add file system monitoring was because I forgot that I had tried this years earlier and encountered the problem with Full Tilt Poker not closing files between writes.

If you open OS X’s “Activity Monitor” and watch CPU usage while Poker Copilot is running, you’ll notice that every 10 seconds or so, Poker Copilot has a sudden peak in CPU usage. That’s because Poker Copilot periodically scans through your hand history folders, looking for new files. Once a new file is found (defined as created within the last ten minutes), it is added to a list of files checked every second for changes. This is a quick process that doesn’t use noticeable system resources, because only a few files need to be checked.

This is one of the frustrating things about writing software (such as Poker Copilot) that is dependent on other third-party software (such as Full Tilt Poker). I don’t have just my own bugs and performance issues to worry about. I also need to code work-arounds for bugs in other software.