Skip to content

Best practice

mhtvsSFrpHdE edited this page Feb 20, 2023 · 18 revisions

Best practice

Learn how do the author may use this tool.

Version 2.0 way

Start from prefetch 2.0, a new work approach introduced to optimize performance.
Version 1.3 rely on manually rule, depending on software and user knowledge, result can differ.
For example, many files are prefetch to RAM, however the software doesn't need these files in the end.

There are ExcludeFolder and PriorityIncludePattern to help filter out unwanted files.

I found sysinternals procmon.exe Process Monitor,
it can record every file a process ever accessed during startup.

Use Firefox as example, download and open procmon, change filter to these:

  1. Process Name is firefox.exe Include
    Only include Firefox activity
  2. Operation contains Reg Exclude
    Remove registry activity
  3. Operation contains Tcp Exclude
    Remove network activity
  4. Any other filter you'd like to add
  5. Make sure Firefox is not run, click clear button to delete exist record
  6. Start Firefox, wait until you feel Firefox is stopped reading disk
  7. Click save button to save csv
  8. Get ParseProcmonLog.py, tested under python 3.9.10.
  9. Run python ParseProcmonLog.py Logfile.CSV firefox path.txt
    The result will save to path.txt, it's a regex pattern.
  10. Open prefetch.ini, add all Firefox program files folder
    to both [PrefetchFolder] and [ExcludeFolder]
  11. For [PriorityIncludePattern]
    Copy and paste the result generated by ParseProcmonLog
  12. You may still need to exclude some noncritical file manually to prevent cache unnecessary files.
    Look at prefetch.cache.ini to figure out what file are matched.

Now, the prefetch.ini should look like this:

[PrefetchFolder]
FirefoxAppdataLocal=C:\\Users\\<your user name>\\AppData\\Local\\Mozilla\\Firefox
FirefoxAppdataRoaming=C:\\Users\\<your user name>\\AppData\\Roaming\\Mozilla\\Firefox
FirefoxProgramFiles=C:\\Program Files\\Mozilla Firefox

[ExcludeFolder]
FirefoxAppdataLocal=C:\\Users\\<your user name>\\AppData\\Local\\Mozilla\\Firefox
FirefoxAppdataRoaming=C:\\Users\\<your user name>\\AppData\\Roaming\\Mozilla\\Firefox
FirefoxProgramFiles=C:\\Program Files\\Mozilla Firefox

[PriorityIncludePattern]
FirefoxFiles=firefox\.exe$|^(?!.*http)^(?!.*archive)^(?!.*log)^(?!.*backup)^(?!.*debug)^(?!.*crash)(.*\\.txt$|.*\\.db-journal$|.*\\.js$|.*\\.metadata$|.*\\.ico$|.*\\.db$|.*\\.tmp$|.*\\.sqlite-journal$|.*\\.baklz4$|.*\\.db-wal$|.*\\.xpi$|.*\\.list$|.*\\.default$|.*\\.files$|.*\\.DLL$|.*\\.sqlite-wal$|.*\\.dll$|.*\\.sbstore$|.*\\.css$|.*\\.dat$|.*\\.lock$|.*\\.test$|.*\\.sqlite-shm$|.*\\.json$|.*\\.log$|.*\\.ja$|.*\\.mozlz4$|.*\\.ttf$|.*\\.stash$|.*\\.little$|.*\\.jsonlz4$|.*\\.sqlite$|.*\\.mdb$|.*\\.vlpset$|.*\\.lz4$|.*\\.bin$|.*\\.filter$|.*\\.info$|.*\\.ini$)

Rocket launch

I have discovered that use prefetch is faster than not use prefetch,
even for the first time on cold boot.

So if a software is start only once and have no plan to restart in the future,
check rocket launch command line argument.
Use StartToTray and prefetch_performance.exe to speed up further,
because no GUI stuff is needed in a rocket launch instance.
Use ReadThreadPriority HighPriority too.

For example, you use a shortcut (*.lnk) to prefetch.exe firefox.ini -rocketLaunch,
instead of default Firefox shortcut to start Firefox.
You may also assign a Firefox icon for it as a complete replacement.

Try to keep only one running prefetch instance at a time to avoid resource contention.
If you have multiple software run on boot and rocket launch,
group them into one prefetch.ini instead of start multiple simultaneously.
You can also set "rocket launch prefetch" as startup item of "background daemon prefetch",
so they executed one after another.

Clear standby list

Other real world program may abuse the standby list.
I had an example at issue 6:
The Steam download can fill standby list without release after task complete.

Rather than reboot computer, use memreduct may or may not worth.
This one has a constantly updated statistics and can't be disabled.
Good news: memreduct support command line options to clear standby list and quit.

Start from prefetch version 2.8, you can use custom tray menu feature to launch memreduct:

  1. Open memreduct as administrator, goto File\Settings\Memory cleaning
  2. Uncheck all but check Standby list* (vista+)
  3. Create a shortcut memreduct.lnk to memreduct.exe
  4. Right-click the shortcut\Properties\Advanced\Check Run as administrator
  5. Modify Target, append -clean after memreduct.exe
  6. Put the shortcut together with prefetch.exe
  7. In prefetch.ini, edit [CustomTrayMenu]
[CustomTrayMenu]
Clear cache=run explorer .\\memreduct.lnk

Run prefetch.exe, right click on tray icon, click on Clear cache to use memreduct.

If you have an operating system before Vista, you can use your own memory cleaning tool chain.