mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 20:02:05 +00:00
Merge pull request #71827 from ClickHouse/turn-off-boundary-alignment-for-table-engines
Disable fs cache setting boundary_alignment for non-disk read
This commit is contained in:
commit
196399bcad
@ -4886,6 +4886,9 @@ Wait time to lock cache for space reservation in filesystem cache
|
||||
)", 0) \
|
||||
DECLARE(Bool, filesystem_cache_prefer_bigger_buffer_size, true, R"(
|
||||
Prefer bigger buffer size if filesystem cache is enabled to avoid writing small file segments which deteriorate cache performance. On the other hand, enabling this setting might increase memory usage.
|
||||
)", 0) \
|
||||
DECLARE(UInt64, filesystem_cache_boundary_alignment, 0, R"(
|
||||
Filesystem cache boundary alignment. This setting is applied only for non-disk read (e.g. for cache of remote table engines / table functions, but not for storage configuration of MergeTree tables). Value 0 means no alignment.
|
||||
)", 0) \
|
||||
DECLARE(UInt64, temporary_data_in_cache_reserve_space_wait_lock_timeout_milliseconds, (10 * 60 * 1000), R"(
|
||||
Wait time to lock cache for space reservation for temporary data in filesystem cache
|
||||
|
@ -85,6 +85,7 @@ static std::initializer_list<std::pair<ClickHouseVersion, SettingsChangesHistory
|
||||
{"filesystem_cache_skip_download_if_exceeds_per_query_cache_write_limit", 1, 1, "Rename of setting skip_download_if_exceeds_query_cache_limit"},
|
||||
{"filesystem_cache_prefer_bigger_buffer_size", true, true, "New setting"},
|
||||
{"read_in_order_use_virtual_row", false, false, "Use virtual row while reading in order of primary key or its monotonic function fashion. It is useful when searching over multiple parts as only relevant ones are touched."},
|
||||
{"filesystem_cache_boundary_alignment", 0, 0, "New setting"},
|
||||
}
|
||||
},
|
||||
{"24.10",
|
||||
|
@ -138,7 +138,7 @@ bool CachedOnDiskReadBufferFromFile::nextFileSegmentsBatch()
|
||||
CreateFileSegmentSettings create_settings(FileSegmentKind::Regular);
|
||||
file_segments = cache->getOrSet(
|
||||
cache_key, file_offset_of_buffer_end, size, file_size.value(),
|
||||
create_settings, settings.filesystem_cache_segments_batch_size, user);
|
||||
create_settings, settings.filesystem_cache_segments_batch_size, user, settings.filesystem_cache_boundary_alignment);
|
||||
}
|
||||
|
||||
return !file_segments->empty();
|
||||
|
@ -62,6 +62,7 @@ struct ReadSettings
|
||||
bool filesystem_cache_allow_background_download_for_metadata_files_in_packed_storage = true;
|
||||
bool filesystem_cache_allow_background_download_during_fetch = true;
|
||||
bool filesystem_cache_prefer_bigger_buffer_size = true;
|
||||
std::optional<size_t> filesystem_cache_boundary_alignment;
|
||||
|
||||
bool use_page_cache_for_disks_without_file_cache = false;
|
||||
bool read_from_page_cache_if_exists_otherwise_bypass_cache = false;
|
||||
|
@ -584,7 +584,8 @@ FileCache::getOrSet(
|
||||
size_t file_size,
|
||||
const CreateFileSegmentSettings & create_settings,
|
||||
size_t file_segments_limit,
|
||||
const UserInfo & user)
|
||||
const UserInfo & user,
|
||||
std::optional<size_t> boundary_alignment_)
|
||||
{
|
||||
ProfileEventTimeIncrement<Microseconds> watch(ProfileEvents::FilesystemCacheGetOrSetMicroseconds);
|
||||
|
||||
@ -596,8 +597,9 @@ FileCache::getOrSet(
|
||||
/// 2. max_file_segments_limit
|
||||
FileSegment::Range result_range = initial_range;
|
||||
|
||||
const auto aligned_offset = FileCacheUtils::roundDownToMultiple(initial_range.left, boundary_alignment);
|
||||
auto aligned_end_offset = std::min(FileCacheUtils::roundUpToMultiple(initial_range.right + 1, boundary_alignment), file_size) - 1;
|
||||
const size_t alignment = boundary_alignment_.value_or(boundary_alignment);
|
||||
const auto aligned_offset = FileCacheUtils::roundDownToMultiple(initial_range.left, alignment);
|
||||
auto aligned_end_offset = std::min(FileCacheUtils::roundUpToMultiple(initial_range.right + 1, alignment), file_size) - 1;
|
||||
|
||||
chassert(aligned_offset <= initial_range.left);
|
||||
chassert(aligned_end_offset >= initial_range.right);
|
||||
|
@ -113,7 +113,8 @@ public:
|
||||
size_t file_size,
|
||||
const CreateFileSegmentSettings & settings,
|
||||
size_t file_segments_limit,
|
||||
const UserInfo & user);
|
||||
const UserInfo & user,
|
||||
std::optional<size_t> boundary_alignment_ = std::nullopt);
|
||||
|
||||
/**
|
||||
* Segments in returned list are ordered in ascending order and represent a full contiguous
|
||||
|
@ -6,11 +6,15 @@ namespace FileCacheUtils
|
||||
|
||||
static size_t roundDownToMultiple(size_t num, size_t multiple)
|
||||
{
|
||||
if (!multiple)
|
||||
return num;
|
||||
return (num / multiple) * multiple;
|
||||
}
|
||||
|
||||
static size_t roundUpToMultiple(size_t num, size_t multiple)
|
||||
{
|
||||
if (!multiple)
|
||||
return num;
|
||||
return roundDownToMultiple(num + multiple - 1, multiple);
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ namespace Setting
|
||||
extern const SettingsMaxThreads max_threads;
|
||||
extern const SettingsBool use_cache_for_count_from_files;
|
||||
extern const SettingsString filesystem_cache_name;
|
||||
extern const SettingsUInt64 filesystem_cache_boundary_alignment;
|
||||
}
|
||||
|
||||
namespace ErrorCodes
|
||||
@ -489,6 +490,8 @@ std::unique_ptr<ReadBufferFromFileBase> StorageObjectStorageSource::createReadBu
|
||||
return object_storage->readObject(StoredObject(path, "", object_size), modified_read_settings);
|
||||
};
|
||||
|
||||
modified_read_settings.filesystem_cache_boundary_alignment = settings[Setting::filesystem_cache_boundary_alignment];
|
||||
|
||||
impl = std::make_unique<CachedOnDiskReadBufferFromFile>(
|
||||
object_info.getPath(),
|
||||
cache_key,
|
||||
|
Loading…
Reference in New Issue
Block a user