Revert some commenting

This commit is contained in:
kssenii 2023-07-30 13:46:40 +02:00
parent 97c1b9d2cf
commit 38f12f0664
2 changed files with 23 additions and 11 deletions

View File

@ -108,7 +108,7 @@ void CachedOnDiskReadBufferFromFile::appendFilesystemCacheLog(
break;
}
cache_log->add(elem);
cache_log->add(std::move(elem));
}
void CachedOnDiskReadBufferFromFile::initialize(size_t offset, size_t size)
@ -259,6 +259,7 @@ CachedOnDiskReadBufferFromFile::getReadBufferForFileSegment(FileSegment & file_s
}
else
{
LOG_TEST(log, "Bypassing cache because `read_from_filesystem_cache_if_exists_otherwise_bypass_cache` option is used");
read_type = ReadType::REMOTE_FS_READ_BYPASS_CACHE;
return getRemoteReadBuffer(file_segment, read_type);
}
@ -344,6 +345,7 @@ CachedOnDiskReadBufferFromFile::getReadBufferForFileSegment(FileSegment & file_s
/// ^
/// file_offset_of_buffer_end
LOG_TEST(log, "Predownload. File segment info: {}", file_segment.getInfoForLog());
chassert(file_offset_of_buffer_end > current_write_offset);
bytes_to_predownload = file_offset_of_buffer_end - current_write_offset;
chassert(bytes_to_predownload < file_segment.range().size());
@ -391,13 +393,13 @@ CachedOnDiskReadBufferFromFile::getImplementationBuffer(FileSegment & file_segme
watch.stop();
// LOG_TEST(
// log,
// "Current read type: {}, read offset: {}, impl read range: {}, file segment: {}",
// toString(read_type),
// file_offset_of_buffer_end,
// read_buffer_for_file_segment->getFileOffsetOfBufferEnd(),
// file_segment.getInfoForLog());
LOG_TEST(
log,
"Current read type: {}, read offset: {}, impl read range: {}, file segment: {}",
toString(read_type),
file_offset_of_buffer_end,
read_buffer_for_file_segment->getFileOffsetOfBufferEnd(),
file_segment.getInfoForLog());
current_file_segment_counters.increment(
ProfileEvents::FileSegmentWaitReadBufferMicroseconds, watch.elapsedMicroseconds());
@ -540,6 +542,7 @@ void CachedOnDiskReadBufferFromFile::predownload(FileSegment & file_segment)
/// downloaded because it intersects with the range he needs.
/// But then first downloader fails and second must continue. In this case we need to
/// download from offset a'' < a', but return buffer from offset a'.
LOG_TEST(log, "Bytes to predownload: {}, caller_id: {}", bytes_to_predownload, FileSegment::getCallerId());
/// chassert(implementation_buffer->getFileOffsetOfBufferEnd() == file_segment.getCurrentWriteOffset(false));
chassert(static_cast<size_t>(implementation_buffer->getPosition()) == file_segment.getCurrentWriteOffset(false));
@ -606,7 +609,7 @@ void CachedOnDiskReadBufferFromFile::predownload(FileSegment & file_segment)
bool continue_predownload = file_segment.reserve(current_predownload_size);
if (continue_predownload)
{
// LOG_TEST(log, "Left to predownload: {}, buffer size: {}", bytes_to_predownload, current_impl_buffer_size);
LOG_TEST(log, "Left to predownload: {}, buffer size: {}", bytes_to_predownload, current_impl_buffer_size);
chassert(file_segment.getCurrentWriteOffset(false) == static_cast<size_t>(implementation_buffer->getPosition()));
@ -700,6 +703,8 @@ bool CachedOnDiskReadBufferFromFile::updateImplementationBufferIfNeeded()
auto current_write_offset = file_segment.getCurrentWriteOffset(true);
bool cached_part_is_finished = current_write_offset == file_offset_of_buffer_end;
LOG_TEST(log, "Current write offset: {}, file offset of buffer end: {}", current_write_offset, file_offset_of_buffer_end);
if (cached_part_is_finished)
{
/// TODO: makes sense to reuse local file reader if we return here with CACHED read type again?

View File

@ -5,6 +5,11 @@
#include <Interpreters/Cache/FileCacheKey.h>
#include <Common/logger_useful.h>
namespace CurrentMetrics
{
extern const Metric FilesystemCacheSizeLimit;
}
namespace DB
{
@ -18,7 +23,10 @@ private:
using LRUQueueIterator = typename LRUQueue::iterator;
public:
LRUFileCachePriority(size_t max_size_, size_t max_elements_) : IFileCachePriority(max_size_, max_elements_) {}
LRUFileCachePriority(size_t max_size_, size_t max_elements_) : IFileCachePriority(max_size_, max_elements_)
{
CurrentMetrics::set(CurrentMetrics::FilesystemCacheSizeLimit, max_size_);
}
size_t getSize(const CacheGuard::Lock &) const override { return current_size; }
@ -37,7 +45,6 @@ private:
void updateSize(int64_t size);
LRUQueue queue;
Poco::Logger * log = &Poco::Logger::get("LRUFileCachePriority");
std::atomic<size_t> current_size = 0;