Metadata configuration and tuning
Optimizing the number of metadata requests that ossfs 2.0 sends to Object Storage Service (OSS) reduces OSS requests and service invocation costs, and improves the concurrent processing and read/write performance of mount targets. This topic covers metadata tuning best practices for typical scenarios.
Configuration items
|
Configuration item |
Description |
|
attr_timeout |
The time in seconds before the metadata cache expires. The default value is 60 s. After expiration, a new request is sent to OSS for the latest metadata. |
|
max_inode_cache_count |
Enables active control over the number of metadata cache entries.
|
|
oss_negative_cache_timeout |
The expiration time for the negative cache, in seconds.
|
|
oss_negative_cache_size |
The maximum number of entries in the negative cache. The default value is 10000. When the number of cache entries exceeds this value, ossfs 2.0 evicts the excess entries based on specific rules. |
Scenarios and suggestions
Reduce OSS requests and accelerate performance
|
Scenario |
Suggestion |
|
Sequentially accessing files from a known file list |
Enable the metadata cache. When you traverse all files in a folder, first run the |
|
Creating many files |
Enable the negative metadata cache. When mounting, specify |
|
This scenario applies if all of the following conditions are met:
|
Example scenario: An ImageNet training task with a dataset of 10 million entries runs on a machine with 64 GiB of memory. The task first traverses the dataset to build metadata, and then reads the files. Suggestion: The read task occupies the machine's page cache, causing the operating system kernel to request metadata eviction. Enable the metadata cache to prevent eviction and keep all metadata in memory, which reduces subsequent OSS metadata requests. The machine has enough memory to cache all 10 million entries.
|
Memory control
|
Access scenario |
Example scenario |
Suggestion |
|
A small number of files are accessed |
Fewer than 1 million files are accessed. |
No special settings are required. The operating system automatically manages the metadata cache. |
|
Files are not accessed repeatedly |
After a folder is accessed, the files in the folder do not need to be read again before the metadata expires. |
No special settings are required. The operating system automatically manages the metadata cache. |
|
Memory usage is a concern |
You want to reduce the metadata memory usage of the ossfs 2.0 process, and metadata performance is not a priority. |
Set the The read and write buffers of ossfs 2.0 also consume memory. For more information, see Mounting options. Reserve some additional memory for actual operations. |
Usage examples
|
Example scenario |
Suggestion |
|
Running an ImageNet training task
|
When you mount the file system, specify By contrast, if you use the default parameters, the training speed is approximately 630 images per second. |
|
Frequently querying small files (for example, 10 KB) or having no concurrent access
|
When you mount the file system, specify |
|
Starting 10 concurrent processes, with each process creating 10,000 empty files
|
When you mount the file system, specify Without the negative cache, the operation takes approximately 680 s, and the number of OSS metadata requests doubles. |
|
Sequentially reading the metadata of files in a single folder
|
When you mount the file system, specify Without running |