in reply to the sands of time(in search of an optimisation)
If you're dealing with Win32/NTFS systems, then there are a couple of vastly more efficient ways to achieve your aim.
The first is to use the Change Notify mechanism (see Win32::ChangeNotify). This would involve creating a daemon or service to register your interest in changes to the file system. It runs perpectually in the background blocking on a change notification. You have it update the database as the changes occur. Very efficient, but requires a permently running process.
The second is to use Change Journaling. Basically this involves asking the system to record all filesystem changes in a journal (file). You can then periodically retrieve those changes, update your DB and reset the journal.
The following comes from (MS)Change jounals:
An automatic backup application is one example of a program that must check for changes to the state of a volume to perform its task. The brute force method of checking for changes in directories or files is to scan the entire volume. However, this is often not an acceptable approach because of the decrease in system performance it would cause. Another method is for the application to register a directory notification (by calling the FindFirstChangeNotification or ReadDirectoryChangesW functions) for the directories to be backed up. This is more efficient than the first method, however, it requires that an application be running at all times. Also, if a large number of directories and files must be backed up, the amount of processing and memory overhead for such an application might also cause the operating system's performance to decrease.
To avoid these disadvantages, the NTFS file system maintains a change journal. When any change is made to a file or directory in a volume, the change journal for that volume is updated with a description of the change and the name of the file or directory.
The first method has a *nix equivalent mechanism. And I believe some *nix filesystems are capable of the second.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: the sands of time(in search of an optimisation)
by spx2 (Deacon) on Mar 04, 2008 at 07:12 UTC | |
by clinton (Priest) on Mar 04, 2008 at 14:24 UTC | |
by spx2 (Deacon) on Mar 09, 2008 at 17:54 UTC |