Enable noobj_cache by default (#1922)

This should improve performance in many situations.  s3fs already
enables the stat cache by default so memorizing noobj makes this more
consistent.  Fixes #1901.
This commit is contained in:
Andrew Gaul
2022-03-12 16:57:31 +09:00
committed by GitHub
parent deaa85c40e
commit 5c57e17b77
6 changed files with 17 additions and 17 deletions

View File

@ -167,11 +167,10 @@ 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.
This option is exclusive with stat_cache_expire, and is left for compatibility with older versions.
.TP
\fB\-o\fR enable_noobj_cache (default is disable)
enable cache entries for the object which does not exist.
s3fs always has to check whether file (or sub directory) exists under object (path) when s3fs does some command, since s3fs has recognized a directory which does not exist and has files or sub directories under itself.
It increases ListBucket request and makes performance bad.
You can specify this option for performance, s3fs memorizes in stat cache that the object (file or directory) does not exist.
\fB\-o\fR disable_noobj_cache (default is enable)
By default s3fs memorizes when an object does not exist up until the stat cache timeout.
This caching can cause staleness for applications.
If disabled, s3fs will not memorize objects and may cause extra HeadObject requests and reduce performance.
.TP
\fB\-o\fR no_check_certificate (by default this option is disabled)
server certificate won't be checked against the available certificate authorities.

View File

@ -123,7 +123,7 @@ pthread_mutex_t StatCache::stat_cache_lock;
//-------------------------------------------------------------------
// Constructor/Destructor
//-------------------------------------------------------------------
StatCache::StatCache() : IsExpireTime(true), IsExpireIntervalType(false), ExpireTime(15 * 60), CacheSize(100000), IsCacheNoObject(false)
StatCache::StatCache() : IsExpireTime(true), IsExpireIntervalType(false), ExpireTime(15 * 60), CacheSize(100000), IsCacheNoObject(true)
{
if(this == StatCache::getStatCacheData()){
stat_cache.clear();

View File

@ -4050,9 +4050,14 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
return 0;
}
if(0 == strcmp(arg, "enable_noobj_cache")){
S3FS_PRN_WARN("enable_noobj_cache is enabled by default and a future version will remove this option.");
StatCache::getStatCacheData()->EnableCacheNoObject();
return 0;
}
if(0 == strcmp(arg, "disable_noobj_cache")){
StatCache::getStatCacheData()->DisableCacheNoObject();
return 0;
}
if(0 == strcmp(arg, "nodnscache")){
S3fsCurl::SetDnsCache(false);
return 0;

View File

@ -204,15 +204,11 @@ static const char help_string[] =
" of the stat cache. This option is exclusive with stat_cache_expire,\n"
" and is left for compatibility with older versions.\n"
"\n"
" enable_noobj_cache (default is disable)\n"
" - enable cache entries for the object which does not exist.\n"
" s3fs always has to check whether file (or sub directory) exists \n"
" under object (path) when s3fs does some command, since s3fs has \n"
" recognized a directory which does not exist and has files or \n"
" sub directories under itself. It increases ListBucket request \n"
" and makes performance bad.\n"
" You can specify this option for performance, s3fs memorizes \n"
" in stat cache that the object (file or directory) does not exist.\n"
" disable_noobj_cache (default is enable)\n"
" - By default s3fs memorizes when an object does not exist up until\n"
" the stat cache timeout. This caching can cause staleness for\n"
" applications. If disabled, s3fs will not memorize objects and may\n"
" cause extra HeadObject requests and reduce performance.\n"
"\n"
" no_check_certificate\n"
" - server certificate won't be checked against the available \n"

View File

@ -399,7 +399,7 @@ function test_external_creation {
local OBJECT_NAME; OBJECT_NAME=$(basename "${PWD}")/"${TEST_TEXT_FILE}"
echo "data" | aws_cli s3 cp - "s3://${TEST_BUCKET_1}/${OBJECT_NAME}"
# shellcheck disable=SC2009
if ps u -p "${S3FS_PID}" | grep -q noobj_cache; then
if ! ps u -p "${S3FS_PID}" | grep -q disable_noobj_cache; then
[ ! -e "${TEST_TEXT_FILE}" ]
fi
sleep 1

View File

@ -44,7 +44,7 @@ if [ -n "${ALL_TESTS}" ]; then
FLAGS=(
"use_cache=${CACHE_DIR} -o ensure_diskfree=${ENSURE_DISKFREE_SIZE} -o fake_diskfree=${FAKE_FREE_DISK_SIZE}"
enable_content_md5
enable_noobj_cache
disable_noobj_cache
"max_stat_cache_size=100"
nocopyapi
nomultipart