From 7729bab27911ecdfc1352441452bde23b27b045e Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 27 Sep 2013 17:26:35 +0000 Subject: [PATCH] dbms: removed sync [#CONV-8822]. --- dbms/include/DB/Interpreters/Settings.h | 5 +---- .../MergeTree/MergeTreeBlockOutputStream.h | 10 +--------- .../Storages/MergeTree/MergedBlockOutputStream.h | 14 +------------- dbms/src/Interpreters/Settings.cpp | 8 ++------ 4 files changed, 5 insertions(+), 32 deletions(-) diff --git a/dbms/include/DB/Interpreters/Settings.h b/dbms/include/DB/Interpreters/Settings.h index 773b11b025e..d46e82c6bc2 100644 --- a/dbms/include/DB/Interpreters/Settings.h +++ b/dbms/include/DB/Interpreters/Settings.h @@ -45,8 +45,6 @@ struct Settings bool extremes; /// Использовать ли кэш разжатых блоков. bool use_uncompressed_cache; - /// Минимальное количество записанных строк, после которого следует делать fsync или sync. 0 - не делать вообще. - size_t min_rows_to_sync; /// Всевозможные ограничения на выполнение запроса. Limits limits; @@ -66,8 +64,7 @@ struct Settings poll_interval(DBMS_DEFAULT_POLL_INTERVAL), distributed_connections_pool_size(DBMS_DEFAULT_DISTRIBUTED_CONNECTIONS_POOL_SIZE), connections_with_failover_max_tries(DBMS_CONNECTION_POOL_WITH_FAILOVER_DEFAULT_MAX_TRIES), - sign_rewrite(false), extremes(false), use_uncompressed_cache(true), - min_rows_to_sync(1000000) + sign_rewrite(false), extremes(false), use_uncompressed_cache(true) { } diff --git a/dbms/include/DB/Storages/MergeTree/MergeTreeBlockOutputStream.h b/dbms/include/DB/Storages/MergeTree/MergeTreeBlockOutputStream.h index 0183fa3f0b0..f301c0ade2a 100644 --- a/dbms/include/DB/Storages/MergeTree/MergeTreeBlockOutputStream.h +++ b/dbms/include/DB/Storages/MergeTree/MergeTreeBlockOutputStream.h @@ -158,16 +158,8 @@ private: writeData(part_tmp_path, column.name, *column.type, *column.column, offset_columns); } - /// Если надо - попросим ОС сбросить данные на диск. - size_t min_rows_to_sync = storage.context.getSettings().min_rows_to_sync; - if (min_rows_to_sync && rows >= min_rows_to_sync) - { - LOG_TRACE(storage.log, "sync()"); - ::sync(); /// Если вызывать fsync для каждого файла по отдельности, то всё больше тормозит. - } - LOG_TRACE(storage.log, "Renaming."); - + /// Переименовываем кусок. Poco::File(part_tmp_path).renameTo(part_res_path); diff --git a/dbms/include/DB/Storages/MergeTree/MergedBlockOutputStream.h b/dbms/include/DB/Storages/MergeTree/MergedBlockOutputStream.h index 7b7b568e9b9..bf6df8cb7da 100644 --- a/dbms/include/DB/Storages/MergeTree/MergedBlockOutputStream.h +++ b/dbms/include/DB/Storages/MergeTree/MergedBlockOutputStream.h @@ -17,7 +17,7 @@ class MergedBlockOutputStream : public IBlockOutputStream public: MergedBlockOutputStream(StorageMergeTree & storage_, UInt16 min_date, UInt16 max_date, UInt64 min_part_id, UInt64 max_part_id, UInt32 level) - : storage(storage_), marks_count(0), index_offset(0), total_rows(0) + : storage(storage_), marks_count(0), index_offset(0) { part_name = storage.getPartName( DayNum_t(min_date), DayNum_t(max_date), @@ -37,7 +37,6 @@ public: void write(const Block & block) { size_t rows = block.rows(); - total_rows += rows; /// Сначала пишем индекс. Индекс содержит значение PK для каждой index_granularity строки. typedef std::vector PrimaryColumns; @@ -87,14 +86,6 @@ public: if (marks_count == 0) throw Exception("Empty part", ErrorCodes::LOGICAL_ERROR); - /// Если надо - попросим ОС сбросить данные на диск. - size_t min_rows_to_sync = storage.context.getSettings().min_rows_to_sync; - if (min_rows_to_sync && total_rows >= min_rows_to_sync) - { - LOG_TRACE(storage.log, "sync()"); - ::sync(); /// Если вызывать fsync для каждого файла по отдельности, то всё больше тормозит. - } - /// Переименовываем кусок. Poco::File(part_tmp_path).renameTo(part_res_path); @@ -140,9 +131,6 @@ private: /// Смещение до первой строчки блока, для которой надо записать индекс. size_t index_offset; - - /// Общее количество записанных строк. - size_t total_rows; typedef std::set OffsetColumns; diff --git a/dbms/src/Interpreters/Settings.cpp b/dbms/src/Interpreters/Settings.cpp index e4ab1288e36..e5cfce18de7 100644 --- a/dbms/src/Interpreters/Settings.cpp +++ b/dbms/src/Interpreters/Settings.cpp @@ -32,7 +32,6 @@ void Settings::set(const String & name, const Field & value) else if (name == "sign_rewrite") sign_rewrite = safeGet(value); else if (name == "extremes") extremes = safeGet(value); else if (name == "use_uncompressed_cache") use_uncompressed_cache = safeGet(value); - else if (name == "min_rows_to_sync") min_rows_to_sync = safeGet(value); else if (name == "profile") setProfile(get(value)); else if (!limits.trySet(name, value)) throw Exception("Unknown setting " + name, ErrorCodes::UNKNOWN_SETTING); @@ -56,8 +55,7 @@ void Settings::set(const String & name, ReadBuffer & buf) || name == "connections_with_failover_max_tries" || name == "sign_rewrite" || name == "extremes" - || name == "use_uncompressed_cache" - || name == "min_rows_to_sync") + || name == "use_uncompressed_cache") { UInt64 value = 0; readVarUInt(value, buf); @@ -91,8 +89,7 @@ void Settings::set(const String & name, const String & value) || name == "connections_with_failover_max_tries" || name == "sign_rewrite" || name == "extremes" - || name == "use_uncompressed_cache" - || name == "min_rows_to_sync") + || name == "use_uncompressed_cache") { set(name, parse(value)); } @@ -153,7 +150,6 @@ void Settings::serialize(WriteBuffer & buf) const writeStringBinary("sign_rewrite", buf); writeVarUInt(sign_rewrite, buf); writeStringBinary("extremes", buf); writeVarUInt(extremes, buf); writeStringBinary("use_uncompressed_cache", buf); writeVarUInt(use_uncompressed_cache, buf); - writeStringBinary("min_rows_to_sync", buf); writeVarUInt(min_rows_to_sync, buf); limits.serialize(buf);