How can I invalidate the file system cache?

后端 未结 5 1780
我在风中等你
我在风中等你 2020-11-29 22:25

I want to measure/optimize the "cold boot" startup performance of an application, and it\'s difficult to do this without an actual reboot, which is obviously not a

5条回答
  •  旧巷少年郎
    2020-11-29 23:03

    What David said. Create a large file, however many GB you need, and each time you want to reset your file cache, make a copy of the file. Then make sure you delete the old file.

    So, create BIGFILE1.DAT, copy it to BIGFILE2.DAT, and then delete BIGFILE1.DAT (which removes it from the disk and the cache). Next time, just reverse the process.

    Addenda:

    Well, the other option is to take the files that are mapped, and copy them to new files, delete the old ones, and rename the new files back to the old ones. The cache is backed by a file. If the file "goes away" so does the cache.

    If you can identify these files, and they're not shared by the system/other running programs, this should be simple to script and, ideally, run faster than copy 6G of files around.

提交回复
热议问题