Created attachment 594368 [details]
Startup time opt breakdown
I was profiling nsLocalFileWin and noticed a slowdown on Windows startup.
About 30-60ms was spent copying a single file on startup.
The file copy happens on the *main thread*.
The file that is copied is sessionStore.js to sessionstore.bak.
The file is <1KB on my profile and tests, but I've seen this file up to 400KB on my other unused profiles.
The slowdown happens after mozilla::StartupTimeline::FIRST_PAINT but before StartupTimeline::SESSION_RESTORED.
The slowdown was completely removed and accounted for 30ms-60ms of startup time.
Bug 545650 introduced the no buffering flag when copying files to solve a bug for network drives. This landed in March 2011. On startup, we use the flag for copying sessionstore to a backup location, and this location is not on a network drive.
With the flag the copy takes 30-60ms. Without the flag the copy takes less than 1ms.
I've noticed this file copy operation using xperf in the past, but this optimization was done using my local simple profiler independent of that.
I confirmed these findings using the about:startup extension.
The 20 run average for session restored is 1016.27 vs 963.14 (53.13ms savings)
Please see the attached screenshot for a breakdown.
Created attachment 594370 [details] [diff] [review]
See also Bug 716174.
Thanks for the heads up khuey, I put some info in that bug about the post effects after this lands.
jimm: I tried the remote drive detection code with both mapped drive paths and UNC paths by the way.
With the browser open for only a couple minutes by the way there were 5 other copy calls, so this should save time in general as well.
Brian see 716174.
Taras see Comment 2 :P
Comment on attachment 594370 [details] [diff] [review]
Review of attachment 594370 [details] [diff] [review]:
Nice little bit of optimization - thanks!
Thanks for the review! Pushed to try: