Last updated at 4:41 pm UTC on 8 November 2015
Contributed by Dave Lewis
November 2015: The latest versions of DirectoryPlugin and DirectoryPluginAccess are maintained at http://www.squeaksource.com in project DirectoryPlugin.
DirectoryPlugin provides access to a Posix directory stream for efficient access to directory contents. It also provides methods for testing file status and how to creating directory entries for a files and directories.
The directory stream primitives use the address of a directory stream as a handle to identify a directory stream. This permits several directory streams to be opened and manipulated independently by separate Smalltalk processes. However, care must be taken to avoid passing the handle for an invalid directory stream (such as one which has already been closed) to one of these methods.
The plugin has been tested on Linux and on Windows. The directory stream support produces a performance improvement only on Unix (Linux) systems. The file access primitives provide substantial improvements for both Unix and Windows systems. Other platforms have not been tested.
DirectoryPluginAccess provides access to primitives in DirectoryPlugin, along with utility methods for various directory and file access functions.
DirectoryPlugin version 1.5 (6-Aug-2003)
Download current version DirectoryPluginV1-5-dtl.sar for Squeak 3.6
Version 1.5 replaces 1.4 (4-Aug-2003), and adds stub methods to the plugin to prevent warning messages from the VM (for initialiseModule and shutdownModule).
Previous released version was 1.3 http://swiki.gsug.org:8080/sqfixes/2185.html (13 Feb 2002)
DirectoryPlugin runs on Unix and Windows, and provides a noticable improvement in many directory and file access methods. If you use CommandShell on Unix (Linux), you should see an overall 15X improvement based on timing the CommandShell SUnit tests with and without DirectoryPlugin.
Formerly called UnixFileDirectory, this version is rewritten to permit multiple file streams to be manipulated by different Smalltalk processes. It is renamed to reflect cross platform support, currently Unix and Windows. Other platforms have not been tested.
DirectoryPlugin provides access to file stat calls, which provides significant improvement to methods such as FileDirectory>>isAFileNamed, FileDirectory>>fileExists, UnixFileDirectory>>entryAt:, and similar methods.
DirectoryPlugin provides a significant improvement in directory access speed on platforms with Posix style directory streams. It provides primitives for access to opendir(), readdir() and related calls, as well as stat() calls on named files. On Unix systems, this enables performance improvements for methods such asFileDirectory>>entries and FileDirectory>>fileAndDirectoryNames. The primitives run on Windows also, but do not improve performance.
This change set hooks the directory stream primitives into UnixFileDirectory so they are in effect only for Unix systems. It hooks the file stat primitives into StandardFileStream and FileDirectory, so they provide performance improvements for both Windows and Unix systems.
Performance improvement on my system, running Linux:
- FileDirectory>>directoryContentsFor: is 7.3 times faster
- FileDirectory>>entryAt:ifAbsent: is 148 times faster
- FileDirectory>>fileAndDirectoryNames is 5.2 times faster
- FileDirectory>>fileExists: is 121 times faster
- FileDirectory>>directoryExists: is 104 times faster
- FileDirectory>>fileOrDirectoryExists: is 32 times faster
- StandardFileStream>>isAFileNamed: is 1445 times faster
Performance improvement on my system, running Windows:
- FileDirectory>>directoryContentsFor: (N/A)
- FileDirectory>>entryAt:ifAbsent: (N/A)
- FileDirectory>>fileAndDirectoryNames 1.37 times faster
- FileDirectory>>fileExists: 86 times faster
- FileDirectory>>directoryExists: 80 times faster
- FileDirectory>>fileOrDirectoryExists: 90 times faster
- StandardFileStream>>isAFileNamed: 497 times faster
Primitive access methods are provided on the class side of UnixFileDirectoryPlugin in order to prevent pollution of the current FileDirectory and FileStream hierarchies. Hooks are put into UnixFileDirectory and StandardFileStream to make use of the plugin with the fewest possible changes to these classes.
Performance test methods are also provided on the class side of the plugin to profile the code and demonstrate the performance differences.
- Do proper integration into the base image, preferably in conjunction with adding Flow to Squeak.
- Write SUnit tests to verify correct operation under all the permutations of read/write/execute permissions on files and directories I've already squashed some ugly bugs here, and need to test to make sure I've gotten them all.
- The semantics of #isAFileNamed: are slightly changed. Need to test to verify that the change does not break existing applications.
- Test DirectoryPlugin with SecurityPlugin. Make sure the security functions in DirectoryPlugin work, and find out how much performance degradation accurs with security turned on.