Skip to content
Tcl Source Code View Ticket
Login

View Ticket

speed up filesystem patch

Closed / Accepted682500ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2003-02-07 19:02:00
Here's a first cut at a patch which should speed up 
the filesystem in Tcl 8.4.1.  At least on Windows, 
with this patch Tcl 8.4 is faster in things like:

foreach f [glob -dir $dir *] {
   file stat $f arr
   ...
}

than 8.3, often by a quite a large margin.

I have also attached a file testfs.tcl which I am 
using for benchmarking.

It is untested on Unix.
vincentdarleyplain2003-02-08 02:05:29
File Added - 41785: fsspeed.diff
vincentdarleyplain2003-02-08 02:06:16
Logged In: YES 
user_id=32170

Added test script
vincentdarleyplain2003-02-08 02:06:17
File Added - 41786: testfs.tcl
jcwplain2003-02-08 05:01:25
Logged In: YES 
user_id=1983

confirmed to work (quick test) on Win32 and Linux
- binary tclkits based on these now in http://www.equi4.com/pub/tk/newer/
hobbsplain2003-02-09 10:00:29
Logged In: YES 
user_id=72656

Note that this part of the patch looks highly suspicious to me, 
although the return does seem key to Win not going boom:

@@ -3766,10 +3761,14 @@
     if (objPtr->typePtr == &tclFsPathType) {
 FsPath *fsPathPtr = (FsPath*) objPtr-
>internalRep.otherValuePtr;
 if (fsPathPtr->filesystemEpoch != 
theFilesystemEpoch) {
+    if (objPtr->bytes == NULL) {
+
+    }
     FreeFsPathInternalRep(objPtr);
     objPtr->typePtr = NULL;
     return Tcl_ConvertToType(interp, objPtr, 
&tclFsPathType);
 }
+return TCL_OK;
 if (fsPathPtr->cwdPtr == NULL) {
     return TCL_OK;
 } else {

That's in tclIOUtil.c.  Also, this patch blows the unix test 
suite (no crashes, just lots of errors), so something about it 
isn't correct.  I've isolated it to the tclUnixFile.c change.  That 
looks OK, but I had to revert to the old version for 
correctness.  Note that one simple change erases all 
speedups on Linux.
hobbsplain2003-02-09 11:49:27
Logged In: YES 
user_id=72656

This patch appears incorrect.  I've attached something that 
may be more correct, but there may be more fundamental 
flaws in the changes.
hobbsplain2003-02-09 11:49:30
File Added - 41889: fs-682500.diff
vincentdarleyplain2003-02-10 06:36:24
File Added - 41948: fsspeed2.patch
vincentdarleyplain2003-02-10 06:37:46
Logged In: YES 
user_id=32170

Attached newer patch.  Should work on Linux, Windows 
at least.
hobbsplain2003-02-10 10:48:58
File Added - 41965: fs2-682500.diff

Logged In: YES 
user_id=72656

Attached updated patch.
vincentdarleyplain2003-02-10 19:58:52
Logged In: YES 
user_id=32170

This patch has been applied.  Further improvements are 
definitely still possible, but require a bit more analysis 
first.
hobbsplain2003-02-11 04:31:07
Logged In: YES 
user_id=72656

The current patch is incorrect.  This needs further testing.
hobbsplain2003-02-11 09:08:58
File Added - 42051: fs3-682500.diff

Logged In: YES 
user_id=72656

Attached is the patch with extra failing test.
hobbsplain2003-02-11 09:24:11
File Added - 42054: fs3.1-682500.diff

Logged In: YES 
user_id=72656

And attached is a patch to fs3-682500.diff that corrects the 
failing test.  However, the entire handling of cwdLen, adding 
and subtracting 1 seems incorrect.  For example, 
Tcl_FSGetNormalizedPath then passes cwdLen-1, which 
may also not be correct.  The entire handling of the case for 
cwdLen == 0 may be incorrect in other places.  It is likely 
most prudent to revert this all until a more thorough review 
with additional tests is made.
hobbsplain2003-02-11 09:25:28
File Deleted - 42054: 



File Added - 42055: fs3.1-682500.diff

Logged In: YES 
user_id=72656

Attaching same patch with correct -u formatting this time.
hobbsplain2003-02-11 09:27:09
File Added - 42057: fs4-682500.diff

Logged In: YES 
user_id=72656

And one more time in full (fs4) to make it easy for others ...
vincentdarleyplain2003-02-12 00:28:12
Logged In: YES 
user_id=32170

NB. Jeff has now committed a fixed patch.  We shall see 
if any new bugs turn up over the coming week or two.
hobbsplain2003-02-12 01:56:25
Logged In: YES 
user_id=72656

Let's call this closed and have any bugs introduced be 
reported separately.
Log in (anonymous is fine) to add a comment.

Attachments: