Home
%3CLINGO-SUB%20id%3D%22lingo-sub-723622%22%20slang%3D%22en-US%22%3EInside%20Vista%20SP1%20File%20Copy%20Improvements%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-723622%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20TechNet%20on%20Feb%2004%2C%202008%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20Windows%20Vista%20SP1%20includes%20a%20number%20of%20enhancements%20over%20the%20original%20Vista%20release%20in%20the%20areas%20of%20application%20compatibility%2C%20device%20support%2C%20power%20management%2C%20security%20and%20reliability.%20You%20can%20see%20a%20detailed%20list%20of%20the%20changes%20in%20the%20Notable%20Changes%20in%20Windows%20Vista%20Service%20Pack%201%20whitepaper%20that%20you%20can%20download%20%3CA%20class%3D%22%22%20href%3D%22http%3A%2F%2Fwww.microsoft.com%2Fdownloads%2Fdetails.aspx%3FFamilyID%3De71f0083-1013-4f9c-a3f9-c56e7120a5e9%26amp%3BDisplayLang%3Den%22%20mce_href%3D%22http%3A%2F%2Fwww.microsoft.com%2Fdownloads%2Fdetails.aspx%3FFamilyID%3De71f0083-1013-4f9c-a3f9-c56e7120a5e9%26amp%3BDisplayLang%3Den%20%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20here%20%3C%2FA%3E%20%3C%2FFONT%3E%20%3C%2FSPAN%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20.%20%3C%2FFONT%3E%20%3C%2FFONT%3E%20%3C%2FSPAN%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20One%20of%20the%20improvements%20highlighted%20in%20the%20document%20is%20the%20increased%20performance%20of%20file%20copying%20for%20multiple%20scenarios%2C%20including%20local%20copies%20on%20the%20same%20disk%2C%20copying%20files%20from%20remote%20non-Windows%20Vista%20systems%2C%20and%20copying%20files%20between%20SP1%20systems.%20How%20were%20these%20gains%20achieved%3F%20The%20answer%20is%20a%20complex%20one%20and%20lies%20in%20the%20changes%20to%20the%20file%20copy%20engine%20between%20Windows%20XP%20and%20Vista%20and%20further%20changes%20in%20SP1.%20Everyone%20copies%20files%2C%20so%20I%20thought%20it%20would%20be%20worth%20taking%20a%20break%20from%20the%20%E2%80%9CCase%20of%E2%80%A6%E2%80%9D%20posts%20and%20dive%20deep%20into%20the%20evolution%20of%20the%20copy%20engine%20to%20show%20how%20SP1%20improves%20its%20performance.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20Copying%20a%20file%20seems%20like%20a%20relatively%20straightforward%20operation%3A%20open%20the%20source%20file%2C%20create%20the%20destination%2C%20and%20then%20read%20from%20the%20source%20and%20write%20to%20the%20destination.%20In%20reality%2C%20however%2C%20the%20performance%20of%20copying%20files%20is%20measured%20along%20the%20dimensions%20of%20accurate%20progress%20indication%2C%20CPU%20usage%2C%20memory%20usage%2C%20and%20throughput.%20In%20general%2C%20optimizing%20one%20area%20causes%20degradation%20in%20others.%20Further%2C%20there%20is%20semantic%20information%20not%20available%20to%20copy%20engines%20that%20could%20help%20them%20make%20better%20tradeoffs.%20For%20example%2C%20if%20they%20knew%20that%20you%20weren%E2%80%99t%20planning%20on%20accessing%20the%20target%20of%20the%20copy%20operation%20they%20could%20avoid%20caching%20the%20file%E2%80%99s%20data%20in%20memory%2C%20but%20if%20it%20knew%20that%20the%20file%20was%20going%20to%20be%20immediately%20consumed%20by%20another%20application%2C%20or%20in%20the%20case%20of%20a%20file%20server%2C%20client%20systems%20sharing%20the%20files%2C%20it%20would%20aggressively%20cache%20the%20data%20on%20the%20destination%20system.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CB%20style%3D%22mso-bidi-font-weight%3A%20normal%22%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20File%20Copy%20in%20Previous%20Versions%20of%20Windows%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FB%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%20%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20In%20light%20of%20all%20the%20tradeoffs%20and%20imperfect%20information%20available%20to%20it%2C%20the%20Windows%20file%20copy%20engine%20tries%20to%20handle%20all%20scenarios%20well.%20Prior%20to%20Windows%20Vista%2C%20it%20took%20the%20straightforward%20approach%20of%20opening%20both%20the%20source%20and%20destination%20files%20in%20cached%20mode%20and%20marching%20sequentially%20through%20the%20source%20file%20reading%2064KB%20(60KB%20for%20network%20copies%20because%20of%20an%20SMB1.0%20protocol%20limit%20on%20individual%20read%20sizes)%20at%20a%20time%20and%20writing%20out%20the%20data%20to%20the%20destination%20as%20it%20went.%20When%20a%20file%20is%20accessed%20with%20cached%20I%2FO%2C%20as%20opposed%20to%20memory-mapped%20I%2FO%20or%20I%2FO%20with%20the%20no-buffering%20flag%2C%20the%20data%20read%20or%20written%20is%20stored%20in%20memory%2C%20at%20least%20until%20the%20Memory%20Manager%20decides%20that%20the%20memory%20should%20be%20repurposed%20for%20other%20uses%2C%20including%20caching%20the%20data%20of%20other%20files.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20The%20copy%20engine%20relied%20on%20the%20Windows%20Cache%20Manager%20to%20perform%20asynchronous%20read-ahead%2C%20which%20essentially%20reads%20the%20source%20file%20in%20the%20background%20while%20Explorer%20is%20busy%20writing%20data%20to%20a%20different%20disk%20or%20a%20remote%20system.%20It%20also%20relied%20on%20the%20Cache%20Manager%E2%80%99s%20write-behind%20mechanism%20to%20flush%20the%20copied%20file%E2%80%99s%20contents%20from%20memory%20back%20to%20disk%20in%20a%20timely%20manner%20so%20that%20the%20memory%20could%20be%20quickly%20repurposed%20if%20necessary%2C%20and%20so%20that%20data%20loss%20is%20minimized%20in%20the%20face%20of%20a%20disk%20or%20system%20failure.%20You%20can%20see%20the%20algorithm%20at%20work%20in%20this%20%3CA%20class%3D%22%22%20href%3D%22http%3A%2F%2Ftechnet.microsoft.com%2Fen-us%2Fsysinternals%2Fbb896645.aspx%22%20mce_href%3D%22http%3A%2F%2Ftechnet.microsoft.com%2Fen-us%2Fsysinternals%2Fbb896645.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Process%20Monitor%20%3C%2FA%3E%20trace%20of%20a%20256KB%20file%20being%20copied%20on%20Windows%20XP%20from%20one%20directory%20to%20another%20with%20filters%20applied%20to%20focus%20on%20the%20data%20reads%20and%20writes%3A%20%3C%2FFONT%3E%20%3C%2FFONT%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20%3CIMG%20height%3D%22210%22%20mce_src%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815675%2Foriginal.aspx%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815675%2Foriginal.aspx%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121007i0490C987BDAE7AD9%22%20style%3D%22WIDTH%3A%20550px%3B%20HEIGHT%3A%20210px%22%20width%3D%22550%22%20%2F%3E%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%3B%20mso-no-proof%3A%20yes%22%3E%3CSHAPETYPE%20coordsize%3D%2221600%2C21600%22%20filled%3D%22f%22%20id%3D%22_x0000_t75%22%20preferrelative%3D%22t%22%20spt%3D%2275%22%20path%3D%22m%404%405l%404%4011%409%4011%409%405xe%22%20stroked%3D%22f%22%3E%0A%20%20%20%20%20%3CSTROKE%20joinstyle%3D%22miter%22%3E%0A%20%20%20%20%20%3C%2FSTROKE%3E%0A%20%20%20%20%20%3CFORMULAS%3E%0A%20%20%20%20%20%20%3CF%20eqn%3D%22if%20lineDrawn%20pixelLineWidth%200%22%3E%0A%20%20%20%20%20%20%3C%2FF%3E%0A%20%20%20%20%20%20%3CF%20eqn%3D%22sum%20%400%201%200%22%3E%0A%20%20%20%20%20%20%3C%2FF%3E%0A%20%20%20%20%20%20%3CF%20eqn%3D%22sum%200%200%20%401%22%3E%0A%20%20%20%20%20%20%3C%2FF%3E%0A%20%20%20%20%20%20%3CF%20eqn%3D%22prod%20%402%201%202%22%3E%0A%20%20%20%20%20%20%3C%2FF%3E%0A%20%20%20%20%20%20%3CF%20eqn%3D%22prod%20%403%2021600%20pixelWidth%22%3E%0A%20%20%20%20%20%20%3C%2FF%3E%0A%20%20%20%20%20%20%3CF%20eqn%3D%22prod%20%403%2021600%20pixelHeight%22%3E%0A%20%20%20%20%20%20%3C%2FF%3E%0A%20%20%20%20%20%20%3CF%20eqn%3D%22sum%20%400%200%201%22%3E%0A%20%20%20%20%20%20%3C%2FF%3E%0A%20%20%20%20%20%20%3CF%20eqn%3D%22prod%20%406%201%202%22%3E%0A%20%20%20%20%20%20%3C%2FF%3E%0A%20%20%20%20%20%20%3CF%20eqn%3D%22prod%20%407%2021600%20pixelWidth%22%3E%0A%20%20%20%20%20%20%3C%2FF%3E%0A%20%20%20%20%20%20%3CF%20eqn%3D%22sum%20%408%2021600%200%22%3E%0A%20%20%20%20%20%20%3C%2FF%3E%0A%20%20%20%20%20%20%3CF%20eqn%3D%22prod%20%407%2021600%20pixelHeight%22%3E%0A%20%20%20%20%20%20%3C%2FF%3E%0A%20%20%20%20%20%20%3CF%20eqn%3D%22sum%20%4010%2021600%200%22%3E%0A%20%20%20%20%20%20%3C%2FF%3E%0A%20%20%20%20%20%3C%2FFORMULAS%3E%0A%20%20%20%20%20%3CPATH%20gradientshapeok%3D%22t%22%20connecttype%3D%22rect%22%20extrusionok%3D%22f%22%3E%0A%20%20%20%20%20%3C%2FPATH%3E%0A%20%20%20%20%20%3CLOCK%20aspectratio%3D%22t%22%20ext%3D%22edit%22%3E%0A%20%20%20%20%20%3C%2FLOCK%3E%0A%20%20%20%20%3C%2FSHAPETYPE%3E%3C%2FSPAN%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20Explorer%E2%80%99s%20first%20read%20operation%20at%20event%200%20of%20data%20that%E2%80%99s%20not%20present%20in%20memory%20causes%20the%20Cache%20Manager%20to%20perform%20a%20non-cached%20I%2FO%2C%20which%20is%20an%20I%2FO%20that%20reads%20or%20writes%20data%20directly%20to%20the%20disk%20without%20caching%20it%20in%20memory%2C%20to%20fetch%20the%20data%20from%20disk%20at%20event%201%2C%20as%20seen%20in%20the%20stack%20trace%20for%20event%201%3A%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%3B%20mso-no-proof%3A%20yes%22%3E%20%3C%2FSPAN%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20%3CIMG%20height%3D%22342%22%20mce_src%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815676%2Foriginal.aspx%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815676%2Foriginal.aspx%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121008i4D71E41F074511E6%22%20style%3D%22WIDTH%3A%20327px%3B%20HEIGHT%3A%20342px%22%20width%3D%22327%22%20%2F%3E%20%3C%2FFONT%3E%20%3C%2FFONT%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20In%20the%20stack%20trace%2C%20Explorer%E2%80%99s%20call%20to%20ReadFile%20is%20at%20frame%2022%20in%20its%20BaseCopyStream%20function%20and%20the%20Cache%20Manager%20invokes%20the%20non-cached%20read%20indirectly%20by%20touching%20the%20memory%20mapping%20of%20the%20file%20and%20causing%20a%20page%20fault%20at%20frame%208.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20Because%20Explorer%20opens%20the%20file%20with%20the%20sequential-access%20hint%20(not%20visible%20in%20trace)%2C%20the%20Cache%20Manager%E2%80%99s%20read-ahead%20thread%2C%20running%20in%20the%20System%20process%2C%20starts%20to%20aggressively%20read%20the%20file%20on%20behalf%20of%20Explorer%20at%20events%202%20and%203.%20You%20can%20see%20the%20read-ahead%20functions%20in%20the%20stack%20for%20event%202%3A%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%3B%20mso-no-proof%3A%20yes%22%3E%20%3C%2FSPAN%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3CIMG%20height%3D%22276%22%20mce_src%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815677%2Foriginal.aspx%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815677%2Foriginal.aspx%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121009iF65B5030B9F21B87%22%20style%3D%22WIDTH%3A%20315px%3B%20HEIGHT%3A%20276px%22%20width%3D%22315%22%20%2F%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20You%20may%20have%20noticed%20that%20the%20read-ahead%20reads%20are%20initially%20out%20of%20order%20with%20respect%20to%20the%20original%20non-cached%20read%20caused%20by%20the%20first%20Explorer%20read%2C%20which%20can%20cause%20disk%20head%20seeks%20and%20slow%20performance%2C%20but%20Explorer%20stops%20causing%20non-cached%20I%2FOs%20when%20it%20catches%20up%20with%20the%20data%20already%20read%20by%20the%20Cache%20Manager%20and%20its%20reads%20are%20satisfied%20from%20memory.%20%3CSPAN%20style%3D%22mso-spacerun%3A%20yes%22%3E%20%3C%2FSPAN%3E%20The%20Cache%20Manager%20generally%20stays%20128KB%20ahead%20of%20Explorer%20during%20file%20copies.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20At%20event%204%20in%20the%20trace%2C%20Explorer%20issues%20the%20first%20write%20and%20then%20you%20see%20a%20sequence%20of%20interleaved%20reads%20and%20writes.%20At%20the%20end%20of%20the%20trace%20the%20Cache%20Manager%E2%80%99s%20write-behind%20thread%2C%20also%20running%20in%20the%20System%20process%2C%20flushes%20the%20target%20file%E2%80%99s%20data%20from%20memory%20to%20disk%20with%20non-cached%20writes.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CB%20style%3D%22mso-bidi-font-weight%3A%20normal%22%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20Vista%20Improvements%20to%20File%20Copy%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FB%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%20%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20During%20Windows%20Vista%20development%2C%20the%20product%20team%20revisited%20the%20copy%20engine%20to%20improve%20it%20for%20several%20key%20scenarios.%20One%20of%20the%20biggest%20problems%20with%20the%20engine%E2%80%99s%20implementation%20is%20that%20for%20copies%20involving%20lots%20of%20data%2C%20the%20Cache%20Manager%20write-behind%20thread%20on%20the%20target%20system%20often%20can%E2%80%99t%20keep%20up%20with%20the%20rate%20at%20which%20data%20is%20written%20and%20cached%20in%20memory.%20That%20causes%20the%20data%20to%20fill%20up%20memory%2C%20possibly%20forcing%20other%20useful%20code%20and%20data%20out%2C%20and%20eventually%2C%20the%20target%E2%80%99s%20system%E2%80%99s%20memory%20to%20become%20a%20tunnel%20through%20which%20all%20the%20copied%20data%20flows%20at%20a%20rate%20limited%20by%20the%20disk.%20%3CSPAN%20style%3D%22mso-spacerun%3A%20yes%22%3E%20%3C%2FSPAN%3E%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20%3CSPAN%20style%3D%22mso-spacerun%3A%20yes%22%3E%20%3C%2FSPAN%3E%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20Another%20problem%20they%20noted%20was%20that%20when%20copying%20from%20a%20remote%20system%2C%20the%20file%E2%80%99s%20contents%20are%20cached%20twice%20on%20the%20local%20system%3A%20once%20as%20the%20source%20file%20is%20read%20and%20a%20second%20time%20as%20the%20target%20file%20is%20written.%20Besides%20causing%20memory%20pressure%20on%20the%20client%20system%20for%20files%20that%20likely%20won%E2%80%99t%20be%20accessed%20again%2C%20involving%20the%20Cache%20Manager%20introduces%20the%20CPU%20overhead%20that%20it%20must%20perform%20to%20manage%20its%20file%20mappings%20of%20the%20source%20and%20destination%20files.%20%3C%2FFONT%3E%20%3C%2FFONT%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20A%20limitation%20of%20the%20relatively%20small%20and%20interleaved%20file%20operations%20is%20that%20the%20SMB%20file%20system%20driver%2C%20the%20driver%20that%20implements%20the%20Windows%20remote%20file%20sharing%20protocol%2C%20doesn%E2%80%99t%20have%20opportunities%20to%20pipeline%20data%20across%20high-bandwidth%2C%20high-latency%20networks%20like%20WLANs.%20Every%20time%20the%20local%20system%20waits%20for%20the%20remote%20system%20to%20receive%20data%2C%20the%20data%20flowing%20across%20the%20network%20drains%20and%20the%20copy%20pays%20the%20latency%20cost%20as%20the%20two%20systems%20wait%20for%20the%20each%20other%E2%80%99s%20acknowledgement%20and%20next%20block%20of%20data.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20After%20studying%20various%20alternatives%2C%20the%20team%20decided%20to%20implement%20a%20copy%20engine%20that%20tended%20to%20issue%20large%20asynchronous%20non-cached%20I%2FOs%2C%20addressing%20all%20the%20problems%20they%20had%20identified.%20With%20non-cached%20I%2FOs%2C%20copied%20file%20data%20doesn%E2%80%99t%20consume%20memory%20on%20the%20local%20system%2C%20hence%20preserving%20memory%E2%80%99s%20existing%20contents.%20Asynchronous%20large%20file%20I%2FOs%20allow%20for%20the%20pipelining%20of%20data%20across%20high-latency%20network%20connections%2C%20and%20CPU%20usage%20is%20decreased%20because%20the%20Cache%20Manager%20doesn%E2%80%99t%20have%20to%20manage%20its%20memory%20mappings%20and%20inefficiencies%20of%20the%20original%20Vista%20Cache%20Manager%20for%20handling%20large%20I%2FOs%20contributed%20to%20the%20decision%20to%20use%20non-cached%20I%2FOs.%20They%20couldn%E2%80%99t%20make%20I%2FOs%20arbitrarily%20large%2C%20however%2C%20because%20the%20copy%20engine%20needs%20to%20read%20data%20before%20writing%20it%2C%20and%20performing%20reads%20and%20writes%20concurrently%20is%20desirable%2C%20especially%20for%20copies%20to%20different%20disks%20or%20systems.%20Large%20I%2FOs%20also%20pose%20challenges%20for%20providing%20accurate%20time%20estimates%20to%20the%20user%20because%20there%20are%20fewer%20points%20to%20measure%20progress%20and%20update%20the%20estimate.%20The%20team%20did%20note%20a%20significant%20downside%20of%20non-cached%20I%2FOs%2C%20though%3A%20during%20a%20copy%20of%20many%20small%20files%20the%20disk%20head%20constantly%20moves%20around%20the%20disk%2C%20first%20to%20a%20source%20file%2C%20then%20to%20destination%2C%20back%20to%20another%20source%2C%20and%20so%20on.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20After%20much%20analysis%2C%20benchmarking%20and%20tuning%2C%20the%20team%20implemented%20an%20algorithm%20that%20uses%20cached%20I%2FO%20for%20files%20smaller%20than%20256KB%20in%20size.%20For%20files%20larger%20than%20256KB%2C%20the%20engine%20relies%20on%20an%20internal%20matrix%20to%20determine%20the%20number%20and%20size%20of%20non-cached%20I%2FOs%20it%20will%20have%20in%20flight%20at%20once.%20The%20number%20ranges%20from%202%20for%20files%20smaller%20than%202MB%20to%208%20for%20files%20larger%20than%208MB.%20The%20size%20of%20the%20I%2FO%20is%20the%20file%20size%20for%20files%20smaller%20than%201MB%2C%201MB%20for%20files%20up%20to%202MB%2C%20and%202MB%20for%20anything%20larger.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20To%20copy%20a%20file%2016MB%20file%2C%20for%20example%2C%20the%20engine%20issues%20eight%202MB%20asynchronous%20non-cached%20reads%20of%20the%20source%20file%2C%20waits%20for%20the%20I%2FOs%20to%20complete%2C%20issues%20eight%202MB%20asynchronous%20non-cached%20writes%20of%20the%20destination%2C%20waits%20again%20for%20the%20writes%20to%20complete%2C%20and%20then%20repeats%20the%20cycle.%20You%20can%20see%20that%20pattern%20in%20this%20Process%20Monitor%20trace%20of%20a%2016MB%20file%20copy%20from%20a%20local%20system%20to%20a%20remote%20one%3A%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%3B%20mso-no-proof%3A%20yes%22%3E%20%3C%2FSPAN%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20%3CIMG%20height%3D%22226%22%20mce_src%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815678%2Foriginal.aspx%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815678%2Foriginal.aspx%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121010i59EBDAC5D451F182%22%20style%3D%22WIDTH%3A%20550px%3B%20HEIGHT%3A%20226px%22%20width%3D%22550%22%20%2F%3E%20%3C%2FFONT%3E%20%3C%2FFONT%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20While%20this%20algorithm%20is%20an%20improvement%20over%20the%20previous%20one%20in%20many%20ways%2C%20it%20does%20have%20some%20drawbacks.%20One%20that%20occurs%20sporadically%20on%20network%20file%20copies%20is%20out-of-order%20write%20operations%2C%20one%20of%20which%20is%20visible%20in%20this%20trace%20of%20the%20receive%20side%20of%20a%20copy%3A%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%3B%20mso-no-proof%3A%20yes%22%3E%20%3C%2FSPAN%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20%3CIMG%20mce_src%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815680%2Foriginal.aspx%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815680%2Foriginal.aspx%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121011i976351035E27F609%22%20%2F%3E%20%3C%2FFONT%3E%20%3C%2FFONT%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20Note%20how%20the%20write%20operation%20offsets%20jump%20from%20327%2C680%20to%20458%2C752%2C%20skipping%20the%20block%20at%20offset%20393%2C216.%20That%20skip%20causes%20a%20disk%20head%20seek%20and%20forces%20NTFS%20to%20issue%20an%20unnecessary%20write%20operation%20to%20the%20skipped%20region%20to%20zero%20that%20part%20of%20the%20file%2C%20which%20is%20why%20there%20are%20two%20writes%20to%20offset%20393%2C216.%20You%20can%20see%20NTFS%20calling%20the%20Cache%20Manager%E2%80%99s%20CcZeroData%20function%20to%20zero%20the%20skipped%20block%20in%20the%20stack%20trace%20for%20the%20highlighted%20event%3A%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%3B%20mso-no-proof%3A%20yes%22%3E%20%3C%2FSPAN%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3CIMG%20height%3D%22258%22%20mce_src%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815683%2Foriginal.aspx%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815683%2Foriginal.aspx%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121012iB1374E4C02D62D8D%22%20style%3D%22WIDTH%3A%20309px%3B%20HEIGHT%3A%20258px%22%20width%3D%22309%22%20%2F%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20A%20bigger%20problem%20with%20using%20non-cached%20I%2FO%20is%20that%20performance%20can%20suffer%20in%20publishing%20scenarios.%20If%20you%20copy%20a%20group%20of%20files%20to%20a%20file%20share%20that%20represents%20the%20contents%20of%20a%20Web%20site%20for%20example%2C%20the%20Web%20server%20must%20read%20the%20files%20from%20disk%20when%20it%20first%20accesses%20them.%20This%20obviously%20applies%20to%20servers%2C%20but%20most%20copy%20operations%20are%20publishing%20scenarios%20even%20on%20client%20systems%2C%20because%20the%20appearance%20of%20new%20files%20causes%20desktop%20search%20indexing%2C%20triggers%20antivirus%20and%20antispyware%20scans%2C%20and%20queues%20Explorer%20to%20generate%20thumbnails%20for%20display%20on%20the%20parent%20directory%E2%80%99s%20folder%20icon.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20Perhaps%20the%20biggest%20drawback%20of%20the%20algorithm%2C%20and%20the%20one%20that%20has%20caused%20many%20Vista%20users%20to%20complain%2C%20is%20that%20for%20copies%20involving%20a%20large%20group%20of%20files%20between%20256KB%20and%20tens%20of%20MB%20in%20size%2C%20the%20perceived%20performance%20of%20the%20copy%20can%20be%20significantly%20worse%20than%20on%20Windows%20XP.%20That%E2%80%99s%20because%20the%20previous%20algorithm%E2%80%99s%20use%20of%20cached%20file%20I%2FO%20lets%20Explorer%20finish%20writing%20destination%20files%20to%20memory%20and%20dismiss%20the%20copy%20dialog%20long%20before%20the%20Cache%20Manager%E2%80%99s%20write-behind%20thread%20has%20actually%20committed%20the%20data%20to%20disk%3B%20with%20Vista%E2%80%99s%20non-cached%20implementation%2C%20Explorer%20is%20forced%20to%20wait%20for%20each%20write%20operation%20to%20complete%20before%20issuing%20more%2C%20and%20ultimately%20for%20all%20copied%20data%20to%20be%20on%20disk%20before%20indicating%20a%20copy%E2%80%99s%20completion.%20In%20Vista%2C%20Explorer%20also%20waits%2012%20seconds%20before%20making%20an%20estimate%20of%20the%20copy%E2%80%99s%20duration%20and%20the%20estimation%20algorithm%20is%20sensitive%20to%20fluctuations%20in%20the%20copy%20speed%2C%20both%20of%20which%20exacerbate%20user%20frustration%20with%20slower%20copies.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CB%20style%3D%22mso-bidi-font-weight%3A%20normal%22%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20SP1%20Improvements%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FB%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%20%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20During%20Vista%20SP1%E2%80%99s%20development%2C%20the%20product%20team%20decided%20to%20revisit%20the%20copy%20engine%20to%20explore%20ways%20to%20improve%20both%20the%20real%20and%20perceived%20performance%20of%20copy%20operations%20for%20the%20cases%20that%20suffered%20in%20the%20new%20implementation.%20The%20biggest%20change%20they%20made%20was%20to%20go%20back%20to%20using%20cached%20file%20I%2FO%20again%20for%20all%20file%20copies%2C%20both%20local%20and%20remote%2C%20with%20one%20exception%20that%20I%E2%80%99ll%20describe%20shortly.%20With%20caching%2C%20perceived%20copy%20time%20and%20the%20publishing%20scenario%20both%20improve.%20However%2C%20several%20significant%20changes%20in%20both%20the%20file%20copy%20algorithm%20and%20the%20platform%20were%20required%20to%20address%20the%20shortcomings%20of%20cached%20I%2FO%20I%E2%80%99ve%20already%20noted.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20The%20one%20case%20where%20the%20SP1%20file%20copy%20engine%20doesn't%20use%20caching%20is%20for%20remote%20file%20copies%2C%20where%20it%20prevents%20the%20double-caching%20problem%20by%20leveraging%20support%20in%20the%20Windows%20client-side%20remote%20file%20system%20driver%2C%20Rdbss.sys.%20It%20does%20so%20by%20issuing%20a%20command%20to%20the%20driver%20that%20tells%20it%20not%20to%20cache%20a%20remote%20file%20on%20the%20local%20system%20as%20it%20is%20being%20read%20or%20written.%20You%20can%20see%20the%20command%20being%20issued%20by%20Explorer%20in%20the%20following%20Process%20Monitor%20capture%3A%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%3B%20mso-no-proof%3A%20yes%22%3E%20%3C%2FSPAN%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20%3CIMG%20mce_src%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815681%2Foriginal.aspx%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815681%2Foriginal.aspx%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121013i35645BAF8C61613E%22%20%2F%3E%20%3C%2FFONT%3E%20%3C%2FFONT%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20Another%20enhancement%20for%20remote%20copies%20is%20the%20pipelined%20I%2FOs%20issued%20by%20the%20SMB2%20file%20system%20driver%2C%20srv2.sys%2C%20which%20is%20new%20to%20Windows%20Vista%20and%20Windows%20Server%202008.%20Instead%20of%20issuing%2060KB%20I%2FOs%20across%20the%20network%20like%20the%20original%20SMB%20implementation%2C%20SMB2%20issues%20pipelined%2064KB%20I%2FOs%20so%20that%20when%20it%20receives%20a%20large%20I%2FO%20from%20an%20application%2C%20it%20will%20issue%20multiple%2064KB%20I%2FOs%20concurrently%2C%20allowing%20for%20the%20data%20to%20stream%20to%20or%20from%20the%20remote%20system%20with%20fewer%20latency%20stalls.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20The%20copy%20engine%20also%20issues%20four%20initial%20I%2FOs%20of%20sizes%20ranging%20from%20128KB%20to%201MB%2C%20depending%20on%20the%20size%20of%20the%20file%20being%20copied%2C%20which%20triggers%20the%20Cache%20Manager%20read-ahead%20thread%20to%20issue%20large%20I%2FOs.%20The%20platform%20change%20made%20in%20SP1%20to%20the%20Cache%20Manager%20has%20it%20perform%20larger%20I%2FO%20for%20both%20read-ahead%20and%20write-behind.%20The%20larger%20I%2FOs%20are%20only%20possible%20because%20of%20work%20done%20in%20the%20original%20Vista%20I%2FO%20system%20to%20support%20I%2FOs%20larger%20than%2064KB%2C%20which%20was%20the%20limit%20in%20previous%20versions%20of%20Windows.%20Larger%20I%2FOs%20also%20improve%20performance%20on%20local%20copies%20because%20there%20are%20fewer%20disk%20accesses%20and%20disk%20seeks%2C%20and%20it%20enables%20the%20Cache%20Manager%20write-behind%20thread%20to%20better%20keep%20up%20with%20the%20rate%20at%20which%20memory%20fills%20with%20copied%20file%20data.%20That%20reduces%2C%20though%20not%20necessarily%20eliminates%2C%20memory%20pressure%20that%20causes%20active%20memory%20contents%20to%20be%20discarded%20during%20a%20copy.%20Finally%2C%20for%20remote%20copies%20the%20large%20I%2FOs%20let%20the%20SMB2%20driver%20use%20pipelining.%20The%20Cache%20Manager%20issues%20read%20I%2FOs%20that%20are%20twice%20the%20size%20of%20the%20I%2FO%20issued%20by%20the%20application%2C%20up%20to%20a%20maximum%20of%202MB%20on%20Vista%20and%2016MB%20on%20Server%202008%2C%20and%20write%20I%2FOs%20of%20up%20to%201MB%20in%20size%20on%20Vista%20and%20up%20to%2032MB%20on%20Server%202008.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20This%20trace%20excerpt%20of%20a%2016MB%20file%20copy%20from%20one%20SP1%20system%20to%20another%20shows%201MB%20I%2FOs%20issued%20by%20Explorer%20and%20a%202MB%20Cache%20Manager%20read-ahead%2C%20which%20is%20distinguished%20by%20its%20non-cached%20I%2FO%20flag%3A%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%3B%20mso-no-proof%3A%20yes%22%3E%20%3C%2FSPAN%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20%3CIMG%20height%3D%22116%22%20mce_src%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815685%2Foriginal.aspx%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F2815685%2Foriginal.aspx%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121014i62D19E5C89767007%22%20style%3D%22WIDTH%3A%20550px%3B%20HEIGHT%3A%20116px%22%20width%3D%22550%22%20%2F%3E%20%3C%2FFONT%3E%20%3C%2FFONT%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20Unfortunately%2C%20the%20SP1%20changes%2C%20while%20delivering%20consistently%20better%20performance%20than%20previous%20versions%20of%20Windows%2C%20can%20be%20slower%20than%20the%20original%20Vista%20release%20in%20a%20couple%20of%20specific%20cases.%20The%20first%20is%20when%20copying%20to%20or%20from%20a%20Server%202003%20system%20over%20a%20slow%20network.%20The%20original%20Vista%20copy%20engine%20would%20deliver%20a%20high-speed%20copy%2C%20but%2C%20because%20of%20the%20out-of-order%20I%2FO%20problem%20I%20mentioned%20earlier%2C%20trigger%20pathologic%20behavior%20in%20the%20Server%202003%20Cache%20Manager%20that%20could%20cause%20all%20of%20the%20server%E2%80%99s%20memory%20to%20be%20filled%20with%20copied%20file%20data.%20The%20SP1%20copy%20engine%20changes%20avoid%20that%2C%20but%20because%20the%20engine%26nbsp%3Bissues%2032KB%20I%2FOs%20instead%20of%2060KB%20I%2FOs%2C%20the%20throughput%20it%20achieves%20on%20high-latency%20connections%20can%20approach%20half%20of%20what%20the%20original%20Vista%20release%20achieved.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20The%20other%20case%20where%20SP1%20might%20not%20perform%20as%20well%20as%20original%20Vista%20is%20for%20large%20file%20copies%20on%20the%20same%20volume.%20Since%20SP1%20issues%20smaller%20I%2FOs%2C%20primarily%20to%20allow%20the%20rest%20of%20the%20system%20to%20have%20better%20access%20to%20the%20disk%20and%20hence%20better%20responsiveness%20during%20a%20copy%2C%20the%20number%20of%20disk%20head%20seeks%20between%20reads%20from%20the%20source%20and%20writes%20to%20the%20destination%20files%20can%20be%20higher%2C%20especially%20on%20disks%20that%20don%E2%80%99t%20avoid%20seeks%20with%20efficient%20internal%20queuing%20algorithms.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20One%20final%20SP1%20change%20worth%20mentioning%20is%20that%20Explorer%20makes%20copy%20duration%20estimates%20much%20sooner%20than%20the%20original%20Vista%20release%20and%20the%20estimation%20algorithm%20is%20more%20accurate.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Calibri%22%20size%3D%223%22%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CB%20style%3D%22mso-bidi-font-weight%3A%20normal%22%3E%20%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20Summary%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FB%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%20%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22MsoNormal%22%20style%3D%22MARGIN%3A%200in%200in%200pt%22%3E%3CSPAN%20style%3D%22COLOR%3A%20%23000000%22%3E%20%3CFONT%20size%3D%223%22%3E%20%3CFONT%20face%3D%22Calibri%22%3E%20File%20copying%20is%20not%20as%20easy%20as%20it%20might%20first%20appear%2C%20but%20the%20product%20team%20took%20feedback%20they%20got%20from%20Vista%20customers%20very%20seriously%20and%20spent%20hundreds%20of%20hours%20evaluating%20different%20approaches%20and%20tuning%20the%20final%20implementation%20to%20restore%20most%20copy%20scenarios%20to%20at%20least%20the%20performance%20of%20previous%20versions%20of%20Windows%20and%20drastically%20improve%20some%20key%20scenarios.%20The%20changes%20apply%20both%20to%20Explorer%20copies%20as%20well%20as%20to%20ones%20initiated%20by%20applications%20using%20the%20%3CA%20class%3D%22%22%20href%3D%22http%3A%2F%2Fmsdn2.microsoft.com%2Fen-us%2Flibrary%2Faa363852.aspx%22%20mce_href%3D%22http%3A%2F%2Fmsdn2.microsoft.com%2Fen-us%2Flibrary%2Faa363852.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20CopyFileEx%20%3C%2FA%3E%20API%20and%20you%E2%80%99ll%20see%20the%20biggest%20improvements%20over%20older%20versions%20of%20Windows%20when%20copying%20files%20on%20high-latency%2C%20high-bandwidth%20networks%20where%20the%20large%20I%2FOs%2C%20SMB2%E2%80%99s%20I%2FO%20pipelining%2C%20and%20Vista%E2%80%99s%20TCP%2FIP%20stack%20receive-window%20auto-tuning%20can%20literally%20deliver%20what%20would%20be%20a%20ten%20minute%20copy%20on%20Windows%20XP%20or%20Server%202003%20in%20one%20minute.%20Pretty%20cool.%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%0A%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-723622%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20TechNet%20on%20Feb%2004%2C%202008%20Windows%20Vista%20SP1%20includes%20a%20number%20of%20enhancements%20over%20the%20original%20Vista%20release%20in%20the%20areas%20of%20application%20compatibility%2C%20device%20support%2C%20power%20management%2C%20security%20and%20reliability.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-723622%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMark%20Russinovich%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft
First published on TechNet on Feb 04, 2008



Windows Vista SP1 includes a number of enhancements over the original Vista release in the areas of application compatibility, device support, power management, security and reliability. You can see a detailed list of the changes in the Notable Changes in Windows Vista Service Pack 1 whitepaper that you can download here . One of the improvements highlighted in the document is the increased performance of file copying for multiple scenarios, including local copies on the same disk, copying files from remote non-Windows Vista systems, and copying files between SP1 systems. How were these gains achieved? The answer is a complex one and lies in the changes to the file copy engine between Windows XP and Vista and further changes in SP1. Everyone copies files, so I thought it would be worth taking a break from the “Case of…” posts and dive deep into the evolution of the copy engine to show how SP1 improves its performance.



Copying a file seems like a relatively straightforward operation: open the source file, create the destination, and then read from the source and write to the destination. In reality, however, the performance of copying files is measured along the dimensions of accurate progress indication, CPU usage, memory usage, and throughput. In general, optimizing one area causes degradation in others. Further, there is semantic information not available to copy engines that could help them make better tradeoffs. For example, if they knew that you weren’t planning on accessing the target of the copy operation they could avoid caching the file’s data in memory, but if it knew that the file was going to be immediately consumed by another application, or in the case of a file server, client systems sharing the files, it would aggressively cache the data on the destination system.



File Copy in Previous Versions of Windows


In light of all the tradeoffs and imperfect information available to it, the Windows file copy engine tries to handle all scenarios well. Prior to Windows Vista, it took the straightforward approach of opening both the source and destination files in cached mode and marching sequentially through the source file reading 64KB (60KB for network copies because of an SMB1.0 protocol limit on individual read sizes) at a time and writing out the data to the destination as it went. When a file is accessed with cached I/O, as opposed to memory-mapped I/O or I/O with the no-buffering flag, the data read or written is stored in memory, at least until the Memory Manager decides that the memory should be repurposed for other uses, including caching the data of other files.



The copy engine relied on the Windows Cache Manager to perform asynchronous read-ahead, which essentially reads the source file in the background while Explorer is busy writing data to a different disk or a remote system. It also relied on the Cache Manager’s write-behind mechanism to flush the copied file’s contents from memory back to disk in a timely manner so that the memory could be quickly repurposed if necessary, and so that data loss is minimized in the face of a disk or system failure. You can see the algorithm at work in this Process Monitor trace of a 256KB file being copied on Windows XP from one directory to another with filters applied to focus on the data reads and writes:






Explorer’s first read operation at event 0 of data that’s not present in memory causes the Cache Manager to perform a non-cached I/O, which is an I/O that reads or writes data directly to the disk without caching it in memory, to fetch the data from disk at event 1, as seen in the stack trace for event 1:





In the stack trace, Explorer’s call to ReadFile is at frame 22 in its BaseCopyStream function and the Cache Manager invokes the non-cached read indirectly by touching the memory mapping of the file and causing a page fault at frame 8.



Because Explorer opens the file with the sequential-access hint (not visible in trace), the Cache Manager’s read-ahead thread, running in the System process, starts to aggressively read the file on behalf of Explorer at events 2 and 3. You can see the read-ahead functions in the stack for event 2:





You may have noticed that the read-ahead reads are initially out of order with respect to the original non-cached read caused by the first Explorer read, which can cause disk head seeks and slow performance, but Explorer stops causing non-cached I/Os when it catches up with the data already read by the Cache Manager and its reads are satisfied from memory. The Cache Manager generally stays 128KB ahead of Explorer during file copies.



At event 4 in the trace, Explorer issues the first write and then you see a sequence of interleaved reads and writes. At the end of the trace the Cache Manager’s write-behind thread, also running in the System process, flushes the target file’s data from memory to disk with non-cached writes.



Vista Improvements to File Copy


During Windows Vista development, the product team revisited the copy engine to improve it for several key scenarios. One of the biggest problems with the engine’s implementation is that for copies involving lots of data, the Cache Manager write-behind thread on the target system often can’t keep up with the rate at which data is written and cached in memory. That causes the data to fill up memory, possibly forcing other useful code and data out, and eventually, the target’s system’s memory to become a tunnel through which all the copied data flows at a rate limited by the disk.



Another problem they noted was that when copying from a remote system, the file’s contents are cached twice on the local system: once as the source file is read and a second time as the target file is written. Besides causing memory pressure on the client system for files that likely won’t be accessed again, involving the Cache Manager introduces the CPU overhead that it must perform to manage its file mappings of the source and destination files.



A limitation of the relatively small and interleaved file operations is that the SMB file system driver, the driver that implements the Windows remote file sharing protocol, doesn’t have opportunities to pipeline data across high-bandwidth, high-latency networks like WLANs. Every time the local system waits for the remote system to receive data, the data flowing across the network drains and the copy pays the latency cost as the two systems wait for the each other’s acknowledgement and next block of data.



After studying various alternatives, the team decided to implement a copy engine that tended to issue large asynchronous non-cached I/Os, addressing all the problems they had identified. With non-cached I/Os, copied file data doesn’t consume memory on the local system, hence preserving memory’s existing contents. Asynchronous large file I/Os allow for the pipelining of data across high-latency network connections, and CPU usage is decreased because the Cache Manager doesn’t have to manage its memory mappings and inefficiencies of the original Vista Cache Manager for handling large I/Os contributed to the decision to use non-cached I/Os. They couldn’t make I/Os arbitrarily large, however, because the copy engine needs to read data before writing it, and performing reads and writes concurrently is desirable, especially for copies to different disks or systems. Large I/Os also pose challenges for providing accurate time estimates to the user because there are fewer points to measure progress and update the estimate. The team did note a significant downside of non-cached I/Os, though: during a copy of many small files the disk head constantly moves around the disk, first to a source file, then to destination, back to another source, and so on.



After much analysis, benchmarking and tuning, the team implemented an algorithm that uses cached I/O for files smaller than 256KB in size. For files larger than 256KB, the engine relies on an internal matrix to determine the number and size of non-cached I/Os it will have in flight at once. The number ranges from 2 for files smaller than 2MB to 8 for files larger than 8MB. The size of the I/O is the file size for files smaller than 1MB, 1MB for files up to 2MB, and 2MB for anything larger.



To copy a file 16MB file, for example, the engine issues eight 2MB asynchronous non-cached reads of the source file, waits for the I/Os to complete, issues eight 2MB asynchronous non-cached writes of the destination, waits again for the writes to complete, and then repeats the cycle. You can see that pattern in this Process Monitor trace of a 16MB file copy from a local system to a remote one:





While this algorithm is an improvement over the previous one in many ways, it does have some drawbacks. One that occurs sporadically on network file copies is out-of-order write operations, one of which is visible in this trace of the receive side of a copy:





Note how the write operation offsets jump from 327,680 to 458,752, skipping the block at offset 393,216. That skip causes a disk head seek and forces NTFS to issue an unnecessary write operation to the skipped region to zero that part of the file, which is why there are two writes to offset 393,216. You can see NTFS calling the Cache Manager’s CcZeroData function to zero the skipped block in the stack trace for the highlighted event:





A bigger problem with using non-cached I/O is that performance can suffer in publishing scenarios. If you copy a group of files to a file share that represents the contents of a Web site for example, the Web server must read the files from disk when it first accesses them. This obviously applies to servers, but most copy operations are publishing scenarios even on client systems, because the appearance of new files causes desktop search indexing, triggers antivirus and antispyware scans, and queues Explorer to generate thumbnails for display on the parent directory’s folder icon.



Perhaps the biggest drawback of the algorithm, and the one that has caused many Vista users to complain, is that for copies involving a large group of files between 256KB and tens of MB in size, the perceived performance of the copy can be significantly worse than on Windows XP. That’s because the previous algorithm’s use of cached file I/O lets Explorer finish writing destination files to memory and dismiss the copy dialog long before the Cache Manager’s write-behind thread has actually committed the data to disk; with Vista’s non-cached implementation, Explorer is forced to wait for each write operation to complete before issuing more, and ultimately for all copied data to be on disk before indicating a copy’s completion. In Vista, Explorer also waits 12 seconds before making an estimate of the copy’s duration and the estimation algorithm is sensitive to fluctuations in the copy speed, both of which exacerbate user frustration with slower copies.



SP1 Improvements


During Vista SP1’s development, the product team decided to revisit the copy engine to explore ways to improve both the real and perceived performance of copy operations for the cases that suffered in the new implementation. The biggest change they made was to go back to using cached file I/O again for all file copies, both local and remote, with one exception that I’ll describe shortly. With caching, perceived copy time and the publishing scenario both improve. However, several significant changes in both the file copy algorithm and the platform were required to address the shortcomings of cached I/O I’ve already noted.



The one case where the SP1 file copy engine doesn't use caching is for remote file copies, where it prevents the double-caching problem by leveraging support in the Windows client-side remote file system driver, Rdbss.sys. It does so by issuing a command to the driver that tells it not to cache a remote file on the local system as it is being read or written. You can see the command being issued by Explorer in the following Process Monitor capture:





Another enhancement for remote copies is the pipelined I/Os issued by the SMB2 file system driver, srv2.sys, which is new to Windows Vista and Windows Server 2008. Instead of issuing 60KB I/Os across the network like the original SMB implementation, SMB2 issues pipelined 64KB I/Os so that when it receives a large I/O from an application, it will issue multiple 64KB I/Os concurrently, allowing for the data to stream to or from the remote system with fewer latency stalls.



The copy engine also issues four initial I/Os of sizes ranging from 128KB to 1MB, depending on the size of the file being copied, which triggers the Cache Manager read-ahead thread to issue large I/Os. The platform change made in SP1 to the Cache Manager has it perform larger I/O for both read-ahead and write-behind. The larger I/Os are only possible because of work done in the original Vista I/O system to support I/Os larger than 64KB, which was the limit in previous versions of Windows. Larger I/Os also improve performance on local copies because there are fewer disk accesses and disk seeks, and it enables the Cache Manager write-behind thread to better keep up with the rate at which memory fills with copied file data. That reduces, though not necessarily eliminates, memory pressure that causes active memory contents to be discarded during a copy. Finally, for remote copies the large I/Os let the SMB2 driver use pipelining. The Cache Manager issues read I/Os that are twice the size of the I/O issued by the application, up to a maximum of 2MB on Vista and 16MB on Server 2008, and write I/Os of up to 1MB in size on Vista and up to 32MB on Server 2008.



This trace excerpt of a 16MB file copy from one SP1 system to another shows 1MB I/Os issued by Explorer and a 2MB Cache Manager read-ahead, which is distinguished by its non-cached I/O flag:





Unfortunately, the SP1 changes, while delivering consistently better performance than previous versions of Windows, can be slower than the original Vista release in a couple of specific cases. The first is when copying to or from a Server 2003 system over a slow network. The original Vista copy engine would deliver a high-speed copy, but, because of the out-of-order I/O problem I mentioned earlier, trigger pathologic behavior in the Server 2003 Cache Manager that could cause all of the server’s memory to be filled with copied file data. The SP1 copy engine changes avoid that, but because the engine issues 32KB I/Os instead of 60KB I/Os, the throughput it achieves on high-latency connections can approach half of what the original Vista release achieved.



The other case where SP1 might not perform as well as original Vista is for large file copies on the same volume. Since SP1 issues smaller I/Os, primarily to allow the rest of the system to have better access to the disk and hence better responsiveness during a copy, the number of disk head seeks between reads from the source and writes to the destination files can be higher, especially on disks that don’t avoid seeks with efficient internal queuing algorithms.



One final SP1 change worth mentioning is that Explorer makes copy duration estimates much sooner than the original Vista release and the estimation algorithm is more accurate.



Summary


File copying is not as easy as it might first appear, but the product team took feedback they got from Vista customers very seriously and spent hundreds of hours evaluating different approaches and tuning the final implementation to restore most copy scenarios to at least the performance of previous versions of Windows and drastically improve some key scenarios. The changes apply both to Explorer copies as well as to ones initiated by applications using the CopyFileEx API and you’ll see the biggest improvements over older versions of Windows when copying files on high-latency, high-bandwidth networks where the large I/Os, SMB2’s I/O pipelining, and Vista’s TCP/IP stack receive-window auto-tuning can literally deliver what would be a ten minute copy on Windows XP or Server 2003 in one minute. Pretty cool.