Force Windows to cache executables without running them?

2

1

Is there a way to force Windows to pre-load certain EXE/DLL binaries into its prefetch/superfetch cache as if they had been executed? I have a particular application that loads pretty slowly on first run but if it's "warm" (recently executed) it starts pretty quickly. I'd like to prime the cache early in the background before the application is needed. But since it shows a UI, I'm looking for a way to do this silently. So simply launching the application it isn't ideal.

Thanks you in advance.


Prompted by David's suggestion in the comments, I wrote a PowerShell script to memory map the files, seek to the end, and close them. I haven't done any controlled tests yet and it could just be my imagination, but Sublime Text (the application in question) appeared to load much more quickly this time around and I haven't used it for several hours.

Josh

Posted 2012-12-05T18:44:03.427

Reputation: 748

@Josh I know this is an old QA, but do you have an updated link for the PS script? The old link 404s so I removed it – bertieb – 2018-12-27T11:08:06.340

1Just never turn your machine off. – martineau – 2012-12-05T19:13:42.500

Yeah, prefetch/superfetch doesn't work that way but thanks. – Josh – 2012-12-05T19:27:11.560

BTW, never turning it off doesn't mean you can't put it to Sleep/Standby or Hibernate mode. – martineau – 2012-12-05T19:31:13.267

Keeping the machine on doesn't keep the binaries warm in cache. If they aren't used, they'll quickly be purged from memory as other applications are launched. I'll probably wind up having to go with a ramdisk & copy on boot. Bleh. – Josh – 2012-12-05T19:43:50.640

1You would write a program that opens those files, memory maps them, and periodically reads from the mappings. – David Schwartz – 2012-12-05T20:57:26.983

Thanks for the suggestion, David. I will give that a shot. Does it matter if I use read access vs read/execute (even though I won't be actually executing anything.) – Josh – 2012-12-06T21:40:53.850

Answers

0

Check the documentation for your program (or just experiment with it; e.g., from a Command Prompt).  See whether there’s anything you can put on the command line that will cause it to exit immediately.  If it displays the GUI even in this mode, run it from a shortcut that has the “Run” control set to “Minimized”:

                                shortcut properties window with Run = Minimized circled

Another approach is to write a batch file that starts your program minimized (with START /MIN), waits a few seconds, and then kills it.

Scott

Posted 2012-12-05T18:44:03.427

Reputation: 17 653

Unfortunately there is no command line argument to start it without a GUI or to make it exit immediately. I can of course start it with PowerShell then sleep a second, then kill it, but that would be disruptive. Also the option to run minimized is simply a suggestion for the application which unfortunately it does not honor. – Josh – 2012-12-06T21:36:07.913