Question & Answer
Question
What is the object cache? Where is it located? What is the actual cache capacity? How can I increase object cache capacity?
Answer
Submitted by Gayathri Priyalakshmi
What is the object cache?
When a user presents a query to the NPS system, the system generates a query plan and multiple C++ code snippets to execute the plan. The query plan determines whether the snippets are compiled and executed on either the SPU or the host. Compilation is expensive so the compiled object files are maintained in an object cache on disk.
The object cache contains the compiled .o files. The object cache directory is subdivided into a number of subdirectories which contain multiple (<nnn>, <nnn>o) file pairs. The <nnn> file contains the .cpp file text and the <nnn>o file is its corresponding object file.
Where is the object cache located ?
NZ_DATA_DIR/cache, typically /nz/data/cache
Capacity is determined by _startup.objCacheFiles registry _variable. Files are deleted when a new entry needs to be added to the cache and it is full. The actual capacity may exceed the size specified by the registry variable.
What is the actual cache capacity ?
The NZ_DATA_DIR/cache directory is organized into a number of subdirectories. The source (.cpp) file and the object (.o) files are saved in these subdirectories.
Number of sub-directories required to support a given cache size = 2(maximum cache size/ number of files that fit into a page) = 2L/P _(_we need to cache both the object and the source .cpp file).We choose a prime number of subdirectories.
Number of subdirectories in cache, D = smallest prime number greater than 2L/P
Number of files per subdirectory, F = P
where L is the cache size and P is the number of files that fit into a page.
Note that the actual number of object files saved in a subdirectory is F/2 as we need to save the source file also.
The default cache size is (smallest prime >= number of subdirectory entries that fit into a page) * (number of files that fit into a page/2) = (349 * 340/2) = 59330
Tests on a Red Hat Linux 2.6.9 ext3 file system show that 340 names (assuming names of four character length) can be stored in a single page of 4KB size. Therefore, we limit the number of files that can be saved in each subdirectory to the number of file names that fit into a page +.
What is the impact of increasing objCacheFiles registry variable?
Increasing the object cache size increases cache access time and the number of files saved on the file system.
For example, if you wish to increase the cache size to 200000, the actual capacity will be 202810 as illustrated in the calculation below.
Number of subdirectories = smallest prime greater than (200000/170) = smallest prime greater than (1176) = 1181
so the actual cache capacity is 200770.
1. Actual number of files stored on disk = 2 * 200770 ( as we cache both .o and .cpp files)
2. Number of pages used for saving the directory info is 1181/340 = 4 pages.
Each subdirectory itself needs 1 page = 1 * 1181 = 1181 pages. So total number of pages = 1181 + 4 = 1185
In the worst case, we need to scan four pages to locate the subdirectory where the .o file is located and one page of the subdirectory to locate the file in this subdirectory.
Historical Number
NZ283613
Was this topic helpful?
Document Information
Modified date:
17 October 2019
UID
swg21575781