--- a/ExternalStream.st Fri Oct 27 15:32:15 2017 +0200
+++ b/ExternalStream.st Fri Oct 27 16:14:37 2017 +0200
@@ -11,7 +11,7 @@
other person. No title to or ownership of the software is
hereby transferred.
"
-'From Smalltalk/X, Version:7.1.0.0 on 27-10-2017 at 15:31:54' !
+'From Smalltalk/X, Version:7.1.0.0 on 27-10-2017 at 16:14:08' !
"{ Package: 'stx:libbasic' }"
@@ -24,7 +24,7 @@
InvalidModeSignal OpenErrorSignal StreamNotOpenSignal
InvalidOperationSignal DefaultEOLMode ReadMode ReadWriteMode
WriteMode AppendMode CreateReadWriteMode StreamIOErrorSignal
- FileOpenTrace MaxNonTenurableExecutors'
+ FileOpenTrace MaxNonTenurableExecutors DefaultCopyBufferSize'
poolDictionaries:''
category:'Streams-External'
!
@@ -1866,6 +1866,47 @@
^ StreamNotOpenError
! !
+!ExternalStream class methodsFor:'defaults'!
+
+bufferSizeForBulkFileCopy
+ "return the size of buffer used when copying big files/buld data from one stream to another.
+ Due to a bug on older Windows systems, the default used
+ is chosen very conservatively, as the copy used to fail with big buffers.
+ However, modern Windows systems seem to not suffer from that bug,
+ and bigger buffer sizes will dramatically increase the performance of
+ copies to/from network drives.
+ Setting DefaultCopyBufferSize allows for fine tuning,
+ in case you run into performance problems, or network buffer failures.
+ When nil, a somewhat conservative compromise is used."
+
+ DefaultCopyBufferSize notNil ifTrue:[^ DefaultCopyBufferSize].
+
+ OperatingSystem isMSDOSlike ifTrue:[
+ OperatingSystem isWin7Like ifTrue:[
+ ^ 64*1024
+ ] ifFalse:[
+ "/ mhmh - NT hangs, when copying bigger blocks to a network drive - why ?
+ ^ 1 * 1024.
+ ].
+ ].
+ ^ 32 * 1024.
+!
+
+defaultCopyBufferSize:anInteger
+ "allows changing the size of buffer used when copying big
+ files/buld data from one stream to another.
+ Due to a bug on older Windows systems, the default used in copyToEndInto:
+ is chosen very conservatively, as the copy used to fail with big buffers.
+ However, modern Windows systems seem to not suffer from that bug,
+ and bigger buffer sizes will dramatically increase the performance of
+ copies to/from network drives.
+ This method allows for fine tuning, in case you run into performance problems,
+ or network buffer failures.
+ When nil, a somewhat conservative compromise is used."
+
+ ^ DefaultCopyBufferSize
+! !
+
!ExternalStream class methodsFor:'error handling'!
errorReporter
@@ -2980,16 +3021,7 @@
Same functionality as copyToEnd:, but reversed arg and receiver
(useful in a cascade message of the writeStream)"
- |bufferSize|
-
- OperatingSystem isMSDOSlike ifTrue:[
- "/ mhmh - NT hangs, when copying bigger blocks to a network drive - why ?
- bufferSize := 1 * 1024.
- ] ifFalse:[
- bufferSize := 8 * 1024.
- ].
-
- ^ inStream copyToEndInto:self bufferSize:bufferSize
+ ^ inStream copyToEndInto:self bufferSize:(self class bufferSizeForBulkFileCopy)
"
|in out|
@@ -3004,19 +3036,7 @@
copyToEndInto:outStream
"copy the data into another stream."
- |bufferSize|
-
- (self isFileStream and:[outStream isFileStream]) ifTrue:[
- bufferSize := 8192 * 8. "/ 64k buffer size
- ] ifFalse:[
- OperatingSystem isMSDOSlike ifTrue:[
- "/ mhmh - NT hangs, when copying bigger blocks to a network drive - why ?
- bufferSize := 1 * 1024.
- ] ifFalse:[
- bufferSize := 8 * 1024.
- ].
- ].
- ^ self copyToEndInto:outStream bufferSize:bufferSize
+ ^ self copyToEndInto:outStream bufferSize:(self class bufferSizeForBulkFileCopy)
"
|in out|