Rate This Document
Findability
Accuracy
Completeness
Readability

Caching Execution Results

Principles

For the same input, the application software has the same output after computing. The computing result can be saved and returned for the same input next time.

Modification Method

Currently, some open-source software has implemented this mechanism. The following is an example:

  1. Nginx buffer

    Based on the locality principle, Nginx uses parameters such as proxy_cache_path to create a copy of the requested content in the local memory. In this way, you do not need to obtain files in the cache from the backend server.

  2. JIT Compilation

    JIT (Just-In-Time) compilation converts the input file into machine code. To improve efficiency, the converted machine code is cached in the memory. In this way, the same input (such as the byte code of the Java program) does not need to be translated again and the cached content is directly returned. If the CPU usage of the C1/C2 Compiler thread of the Java virtual machine is high, the JIT buffer may be insufficient. In this case, you can increase the value of ReservedCodeCacheSize of the Java virtual machine.

  3. MySQL query cache

    MySQL statements are cached in the memory to store the query result. When the query is hit, the parsed SQL statement is directly returned, and the parsing, optimization, and execution phases of the query operation are skipped. If the cached table is modified, the cache of the corresponding table becomes invalid.

    Run the following statement to query the status of the MySQL query cache:

    show status like '%Qcache%';

    Run the query_cache_size and query_cache_type commands to set the MySQL query cache attributes.