This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 46cadc9856cfca06a5f2b8885d32a2d06df9b43f Author: AlexYue <yj976240...@gmail.com> AuthorDate: Fri Jan 26 21:13:32 2024 +0800 [minor](Prefetch) log slow prefetch io operation #30415 --- be/src/common/config.cpp | 2 +- be/src/io/fs/buffered_reader.cpp | 9 +++++++++ be/src/io/fs/buffered_reader.h | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp index 355a90ab7f9..58bb9156b5b 100644 --- a/be/src/common/config.cpp +++ b/be/src/common/config.cpp @@ -1148,7 +1148,7 @@ DEFINE_Int32(ingest_binlog_work_pool_size, "-1"); // Download binlog rate limit, unit is KB/s, 0 means no limit DEFINE_Int32(download_binlog_rate_limit_kbs, "0"); -DEFINE_mInt32(buffered_reader_read_timeout_ms, "20000"); +DEFINE_mInt32(buffered_reader_read_timeout_ms, "600000"); DEFINE_Bool(enable_snapshot_action, "false"); diff --git a/be/src/io/fs/buffered_reader.cpp b/be/src/io/fs/buffered_reader.cpp index 258749fc067..bdbfb04fa30 100644 --- a/be/src/io/fs/buffered_reader.cpp +++ b/be/src/io/fs/buffered_reader.cpp @@ -550,6 +550,10 @@ Status PrefetchBuffer::read_buffer(size_t off, const char* out, size_t buf_len, reset_offset((off / _size) * _size); return read_buffer(off, out, buf_len, bytes_read); } + auto start = std::chrono::steady_clock::now(); + // The baseline time is calculated by dividing the size of each buffer by MB/s. + // If it exceeds this value, it is considered a slow I/O operation. + constexpr auto read_time_baseline = std::chrono::seconds(s_max_pre_buffer_size / 1024 / 1024); { std::unique_lock lck {_lock}; // buffer must be prefetched or it's closed @@ -566,6 +570,11 @@ Status PrefetchBuffer::read_buffer(size_t off, const char* out, size_t buf_len, return Status::OK(); } } + auto duration = std::chrono::duration_cast<std::chrono::seconds>( + std::chrono::steady_clock::now() - start); + if (duration > read_time_baseline) [[unlikely]] { + LOG_WARNING("The prefetch io is too slow"); + } RETURN_IF_ERROR(_prefetch_status); // there is only parquet would do not sequence read // it would read the end of the file first diff --git a/be/src/io/fs/buffered_reader.h b/be/src/io/fs/buffered_reader.h index 2f8eb465cdf..ca939dba94d 100644 --- a/be/src/io/fs/buffered_reader.h +++ b/be/src/io/fs/buffered_reader.h @@ -356,6 +356,8 @@ struct PrefetchBuffer : std::enable_shared_from_this<PrefetchBuffer> { size_t merge_small_ranges(size_t off, int range_index) const; }; +constexpr int64_t s_max_pre_buffer_size = 4 * 1024 * 1024; // 4MB + /** * A buffered reader that prefetch data in the daemon thread pool. * @@ -420,7 +422,6 @@ private: PrefetchRange _file_range; const std::vector<PrefetchRange>* _random_access_ranges = nullptr; const IOContext* _io_ctx = nullptr; - int64_t s_max_pre_buffer_size = 4 * 1024 * 1024; // 4MB std::vector<std::shared_ptr<PrefetchBuffer>> _pre_buffers; int64_t _whole_pre_buffer_size; bool _initialized = false; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org