diff options
author | andreas_kupries <andreas_kupries@noemail.net> | 2001-09-07 17:08:49 (GMT) |
---|---|---|
committer | andreas_kupries <andreas_kupries@noemail.net> | 2001-09-07 17:08:49 (GMT) |
commit | 4dbc4ebad9b7cacc532f3e3195211cd7f36b7ceb (patch) | |
tree | 9c54e718c2fb1b59062694b50579041998e5a071 /win/tclWinFile.c | |
parent | b82d31947c896f1cae71478faeaabd3b8879bf25 (diff) | |
download | tcl-4dbc4ebad9b7cacc532f3e3195211cd7f36b7ceb.zip tcl-4dbc4ebad9b7cacc532f3e3195211cd7f36b7ceb.tar.gz tcl-4dbc4ebad9b7cacc532f3e3195211cd7f36b7ceb.tar.bz2 |
* All the changes below serve to fix bug [219148] which reports a
80x performance hit for file I/O on Win* systems. On my system
it was closer to a 120x hit. Problem report by Uwe Traum <no
email address available>.
The fix goes like this: The obstacle is 'FlushFileBuffers',
executed whenever Tcl writes data to the OS, as Tcl has to wait
for the disk to complete I/O, and disks are slow. We remove that
obstacle. This opens another problem, [file size] reports back
wrong numbers. So for [file size] we add the call back in. As
optimization we keep track of the channels which were written to
and flush only these.
* win/tclWinFile.c (TclpObjStat): Added a call to
'TclWinFlushDirtyChannels'. This ensures that [file size] and
related commands report the correct size of a file even if Tcl
has recently written to it. Unixoid OS's always report the
correct size even for files with pending data, but Win*
syssystem don't. They only report what is actually on disk.
* win/tclWinInt.h: Added declaration of
'TclWinFlushDirtyChannels', making it available to other parts
of the tcl core.
* win/tclWinChan.c (TclWinFlushDirtyChannels): New, internal,
procedure. Goes through the list of open file channels and
forces the OS to flush its file buffers for all which were
written to since the last call of this function. This is an
expensive operation as Tcl has to wait for the OS to complete
actual writes to the disk.
(FileInfo): Added dirty flag required by the procedure above.
(FileOutputProc): Removed flushing of file buffers, setting the
dirty flag instead. This means that the previously incurred
delays do not happen anymore.
(TclWinOpenFileChannel): Added initialization of 'dirty' flag.
FossilOrigin-Name: fe985089acb1bfe378dd292be93a35f418114c35
Diffstat (limited to 'win/tclWinFile.c')
-rw-r--r-- | win/tclWinFile.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c index c62b9ac..1c8a300 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinFile.c,v 1.13 2001/08/30 08:53:15 vincentdarley Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.14 2001/09/07 17:08:50 andreas_kupries Exp $ */ #include "tclWinInt.h" @@ -694,6 +694,14 @@ TclpObjChdir(pathPtr) int result; TCHAR *nativePath; + /* + * Ensure correct file sizes by forcing the OS to write any + * pending data to disk. This is done only for channels which are + * dirty, i.e. have been written to since the last flush here. + */ + + TclWinFlushDirtyChannels (); + nativePath = (TCHAR *) Tcl_FSGetNativePath(pathPtr); result = (*tclWinProcs->setCurrentDirectoryProc)(nativePath); |