Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use instruction release cache to improve the running speed of Linux system

Shulou Source: shulou.com Published: 2022-06-01 13:00:45 10月01日 Update

This article focuses on "Linux how to use instruction release cache to improve the running speed of the system", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "Linux how to use instruction release cache to improve the running speed of the system"!

The caching mechanism of the Linux system is quite advanced, caching for dentry (for VFS to accelerate file pathname to inode conversion), Buffer Cache (for disk block read and write), and Page Cache (for file inode read and write). However, after a large number of file operations, the cache will basically use up memory resources. But in fact, our file operation has been completed, this part of the cache is no longer needed. At this time, can we just watch the cache occupy the memory space?

Therefore, it is still necessary for us to manually free memory under Linux, which is actually the operation of freeing cache.

To achieve the goal of releasing the cache, we first need to understand the key configuration file / proc/sys/vm/drop_caches. The parameter of cache release is recorded in this file, and the default value is 0, that is, the cache is not released. Its value can be any number between 0 and 3, representing different meanings:

0-No release

1-release the page cache

2-release dentries and inodes

3-release all caches

Once we know the parameters, we can use the following instructions to operate according to our needs.

First, we need to use the sync instruction to write all unwritten system buffers to disk, including the modified i-node, the delayed block IBO, and the read-write mapping file. Otherwise, unsaved files may be lost during the release of the cache.

# sync

Next, we need to write the required parameters into the / proc/sys/vm/drop_caches file, for example, if we need to free all caches, enter the following command:

# echo 3 "/ proc/sys/vm/drop_caches

This instruction will take effect as soon as it is entered, and you can query that there is significantly more available memory.

To query the parameters released by the current cache, enter the following instruction:

# cat / proc/sys/vm/drop_caches

At this point, I believe you have a deeper understanding of "Linux how to use instruction release cache to improve the running speed of the system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Cache file instruction system memory parameters speed run faceted query input that is content actual disk learning different practical obvious deeper Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information OPPO Reno MariaDB Redmi vpn