Refactor StatCache words from NoObject to Negative
This commit is contained in:
committed by
Andrew Gaul
parent
778059279b
commit
be28fbc7b8
@ -168,10 +168,16 @@ specify expire time (seconds) for entries in the stat cache and symbolic link ca
|
|||||||
specify expire time (seconds) for entries in the stat cache and symbolic link cache. This expire time is based on the time from the last access time of those cache.
|
specify expire time (seconds) for entries in the stat cache and symbolic link cache. This expire time is based on the time from the last access time of those cache.
|
||||||
This option is exclusive with stat_cache_expire, and is left for compatibility with older versions.
|
This option is exclusive with stat_cache_expire, and is left for compatibility with older versions.
|
||||||
.TP
|
.TP
|
||||||
\fB\-o\fR disable_noobj_cache (default is enable)
|
\fB\-o\fR enable_negative_cache (default is enabled negative cache)
|
||||||
By default s3fs memorizes when an object does not exist up until the stat cache timeout.
|
This option will keep non-existence of objects in a stat cache.
|
||||||
This caching can cause staleness for applications.
|
When this negative cache is enabled, it will not process extra HeadObject requests to search for non-existent objects, improving performance.
|
||||||
If disabled, s3fs will not memorize objects and may cause extra HeadObject requests and reduce performance.
|
This feature is enabled by default, so there is no need to specify it.
|
||||||
|
.TP
|
||||||
|
\fB\-o\fR disable_negative_cache (default is enabled negative cache)
|
||||||
|
By default, s3fs keeps non-existent objects in the stat cache.
|
||||||
|
This option disables this negative caching.
|
||||||
|
This prevents delays in updates due to cache retention.
|
||||||
|
However, it may increase the number of HeadObject requests to check if an object exists, which may decrease performance.
|
||||||
.TP
|
.TP
|
||||||
\fB\-o\fR no_check_certificate (by default this option is disabled)
|
\fB\-o\fR no_check_certificate (by default this option is disabled)
|
||||||
server certificate won't be checked against the available certificate authorities.
|
server certificate won't be checked against the available certificate authorities.
|
||||||
@ -515,13 +521,13 @@ s3fs is a multi-threaded application. Depending on the workload it may use multi
|
|||||||
.TP
|
.TP
|
||||||
s3fs provides several options (e.g. "max_thread_count" option) to control behaviour and thus indirectly the performance. The possible combinations of these options in conjunction with the various S3 backends are so varied that there is no individual recommendation other than the default values. Improved individual settings can be found by testing and measuring.
|
s3fs provides several options (e.g. "max_thread_count" option) to control behaviour and thus indirectly the performance. The possible combinations of these options in conjunction with the various S3 backends are so varied that there is no individual recommendation other than the default values. Improved individual settings can be found by testing and measuring.
|
||||||
.TP
|
.TP
|
||||||
The two options "Enable no object cache" ("\-o enable_noobj_cache") and "Disable support of alternative directory names" ("\-o notsup_compat_dir") can be used to control shared access to the same bucket by different applications:
|
The two options "Enable negative cache" ("\-o enable_negative_cache") and "Disable support of alternative directory names" ("\-o notsup_compat_dir") can be used to control shared access to the same bucket by different applications:
|
||||||
.TP
|
.TP
|
||||||
.IP \[bu]
|
.IP \[bu]
|
||||||
Enable no object cache ("\-o enable_noobj_cache")
|
Enable negative cache ("\-o enable_negative_cache")
|
||||||
.RS
|
.RS
|
||||||
.TP
|
.TP
|
||||||
If a bucket is used exclusively by an s3fs instance, you can enable the cache for non-existent files and directories with "\-o enable_noobj_cache". This eliminates repeated requests to check the existence of an object, saving time and possibly money.
|
If a bucket is used exclusively by an s3fs instance, you can enable the cache for non-existent files and directories with "\-o enable_negative_cache". This eliminates repeated requests to check the existence of an object, saving time and possibly money.
|
||||||
.RE
|
.RE
|
||||||
.IP \[bu]
|
.IP \[bu]
|
||||||
Enable support of alternative directory names ("\-o compat_dir")
|
Enable support of alternative directory names ("\-o compat_dir")
|
||||||
|
|||||||
@ -119,7 +119,7 @@ std::mutex StatCache::stat_cache_lock;
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Constructor/Destructor
|
// Constructor/Destructor
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
StatCache::StatCache() : IsExpireTime(true), IsExpireIntervalType(false), ExpireTime(15 * 60), CacheSize(100'000), IsCacheNoObject(true)
|
StatCache::StatCache() : IsExpireTime(true), IsExpireIntervalType(false), ExpireTime(15 * 60), CacheSize(100'000), UseNegativeCache(true)
|
||||||
{
|
{
|
||||||
if(this == StatCache::getStatCacheData()){
|
if(this == StatCache::getStatCacheData()){
|
||||||
stat_cache.clear();
|
stat_cache.clear();
|
||||||
@ -175,10 +175,10 @@ time_t StatCache::UnsetExpireTime()
|
|||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StatCache::SetCacheNoObject(bool flag)
|
bool StatCache::SetNegativeCache(bool flag)
|
||||||
{
|
{
|
||||||
bool old = IsCacheNoObject;
|
bool old = UseNegativeCache;
|
||||||
IsCacheNoObject = flag;
|
UseNegativeCache = flag;
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ bool StatCache::GetStat(const std::string& key, struct stat* pst, headers_t* met
|
|||||||
|
|
||||||
// No object
|
// No object
|
||||||
if(ent->noobjcache){
|
if(ent->noobjcache){
|
||||||
if(!IsCacheNoObject){
|
if(!UseNegativeCache){
|
||||||
// need to delete this cache.
|
// need to delete this cache.
|
||||||
DelStatHasLock(strpath);
|
DelStatHasLock(strpath);
|
||||||
}else{
|
}else{
|
||||||
@ -275,7 +275,7 @@ bool StatCache::GetStat(const std::string& key, struct stat* pst, headers_t* met
|
|||||||
|
|
||||||
bool StatCache::IsNoObjectCache(const std::string& key, bool overcheck)
|
bool StatCache::IsNoObjectCache(const std::string& key, bool overcheck)
|
||||||
{
|
{
|
||||||
if(!IsCacheNoObject){
|
if(!UseNegativeCache){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const std::lock_guard<std::mutex> lock(StatCache::stat_cache_lock);
|
const std::lock_guard<std::mutex> lock(StatCache::stat_cache_lock);
|
||||||
@ -433,7 +433,7 @@ bool StatCache::UpdateMetaStats(const std::string& key, const headers_t& meta)
|
|||||||
|
|
||||||
bool StatCache::AddNoObjectCache(const std::string& key)
|
bool StatCache::AddNoObjectCache(const std::string& key)
|
||||||
{
|
{
|
||||||
if(!IsCacheNoObject){
|
if(!UseNegativeCache){
|
||||||
return true; // pretend successful
|
return true; // pretend successful
|
||||||
}
|
}
|
||||||
if(CacheSize < 1){
|
if(CacheSize < 1){
|
||||||
|
|||||||
16
src/cache.h
16
src/cache.h
@ -88,7 +88,7 @@ class StatCache
|
|||||||
bool IsExpireIntervalType; // if this flag is true, cache data is updated at last access time.
|
bool IsExpireIntervalType; // if this flag is true, cache data is updated at last access time.
|
||||||
time_t ExpireTime;
|
time_t ExpireTime;
|
||||||
unsigned long CacheSize;
|
unsigned long CacheSize;
|
||||||
bool IsCacheNoObject;
|
bool UseNegativeCache;
|
||||||
symlink_cache_t symlink_cache GUARDED_BY(stat_cache_lock);
|
symlink_cache_t symlink_cache GUARDED_BY(stat_cache_lock);
|
||||||
notruncate_dir_map_t notruncate_file_cache GUARDED_BY(stat_cache_lock);
|
notruncate_dir_map_t notruncate_file_cache GUARDED_BY(stat_cache_lock);
|
||||||
|
|
||||||
@ -126,18 +126,18 @@ class StatCache
|
|||||||
time_t GetExpireTime() const;
|
time_t GetExpireTime() const;
|
||||||
time_t SetExpireTime(time_t expire, bool is_interval = false);
|
time_t SetExpireTime(time_t expire, bool is_interval = false);
|
||||||
time_t UnsetExpireTime();
|
time_t UnsetExpireTime();
|
||||||
bool SetCacheNoObject(bool flag);
|
bool SetNegativeCache(bool flag);
|
||||||
bool EnableCacheNoObject()
|
bool EnableNegativeCache()
|
||||||
{
|
{
|
||||||
return SetCacheNoObject(true);
|
return SetNegativeCache(true);
|
||||||
}
|
}
|
||||||
bool DisableCacheNoObject()
|
bool DisableNegativeCache()
|
||||||
{
|
{
|
||||||
return SetCacheNoObject(false);
|
return SetNegativeCache(false);
|
||||||
}
|
}
|
||||||
bool GetCacheNoObject() const
|
bool IsEnabledNegativeCache() const
|
||||||
{
|
{
|
||||||
return IsCacheNoObject;
|
return UseNegativeCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get stat cache
|
// Get stat cache
|
||||||
|
|||||||
10
src/s3fs.cpp
10
src/s3fs.cpp
@ -4973,13 +4973,13 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
|||||||
StatCache::getStatCacheData()->SetExpireTime(expr_time, true);
|
StatCache::getStatCacheData()->SetExpireTime(expr_time, true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(0 == strcmp(arg, "enable_noobj_cache")){
|
else if(0 == strcmp(arg, "enable_negative_cache") || 0 == strcmp(arg, "enable_noobj_cache")){
|
||||||
S3FS_PRN_WARN("enable_noobj_cache is enabled by default and a future version will remove this option.");
|
S3FS_PRN_WARN("enable_negative_cache(enable_noobj_cache) is enabled by default and a future version will remove this option.");
|
||||||
StatCache::getStatCacheData()->EnableCacheNoObject();
|
StatCache::getStatCacheData()->EnableNegativeCache();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(0 == strcmp(arg, "disable_noobj_cache")){
|
else if(0 == strcmp(arg, "disable_negative_cache") || 0 == strcmp(arg, "disable_noobj_cache")){
|
||||||
StatCache::getStatCacheData()->DisableCacheNoObject();
|
StatCache::getStatCacheData()->DisableNegativeCache();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(0 == strcmp(arg, "nodnscache")){
|
else if(0 == strcmp(arg, "nodnscache")){
|
||||||
|
|||||||
@ -204,11 +204,20 @@ static constexpr char help_string[] =
|
|||||||
" of the stat cache. This option is exclusive with stat_cache_expire,\n"
|
" of the stat cache. This option is exclusive with stat_cache_expire,\n"
|
||||||
" and is left for compatibility with older versions.\n"
|
" and is left for compatibility with older versions.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" disable_noobj_cache (default is enable)\n"
|
" enable_negative_cache (default is enabled negative cache)\n"
|
||||||
" - By default s3fs memorizes when an object does not exist up until\n"
|
" - This option will keep non-existence of objects in a stat cache.\n"
|
||||||
" the stat cache timeout. This caching can cause staleness for\n"
|
" When this negative cache is enabled, it will not process extra\n"
|
||||||
" applications. If disabled, s3fs will not memorize objects and may\n"
|
" HeadObject requests to search for non-existent objects, improving\n"
|
||||||
" cause extra HeadObject requests and reduce performance.\n"
|
" performance.\n"
|
||||||
|
" This feature is enabled by default, so there is no need to specify\n"
|
||||||
|
" it.\n"
|
||||||
|
"\n"
|
||||||
|
" disable_negative_cache (default is enabled negative cache)\n"
|
||||||
|
" - By default, s3fs keeps non-existent objects in the stat cache.\n"
|
||||||
|
" This option disables this negative caching.\n"
|
||||||
|
" This prevents delays in updates due to cache retention.\n"
|
||||||
|
" However, it may increase the number of HeadObject requests to check\n"
|
||||||
|
" if an object exists, which may decrease performance.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" no_check_certificate\n"
|
" no_check_certificate\n"
|
||||||
" - server certificate won't be checked against the available \n"
|
" - server certificate won't be checked against the available \n"
|
||||||
|
|||||||
Reference in New Issue
Block a user