summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/benchmark
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Telegram/tdlib/td/benchmark')
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_actor.cpp37
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_crypto.cpp24
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_db.cpp20
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_empty.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_handshake.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_http.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_http_server.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_http_server_cheat.cpp3
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_http_server_fast.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_log.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_misc.cpp51
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_queue.cpp7
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/bench_tddb.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/check_proxy.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/check_tls.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/hashmap_build.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/hashset_memory.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/rmdir.cpp20
-rw-r--r--protocols/Telegram/tdlib/td/benchmark/wget.cpp2
20 files changed, 98 insertions, 90 deletions
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_actor.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_actor.cpp
index afe94ca3c1..7045b80292 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_actor.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_actor.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -46,14 +46,16 @@ class ActorTraits<TestActor> {
} // namespace td
class CreateActorBench final : public td::Benchmark {
- td::ConcurrentScheduler scheduler_{0, 0};
+ td::unique_ptr<td::ConcurrentScheduler> scheduler_;
void start_up() final {
- scheduler_.start();
+ scheduler_ = td::make_unique<td::ConcurrentScheduler>(0, 0);
+ scheduler_->start();
}
void tear_down() final {
- scheduler_.finish();
+ scheduler_->finish();
+ scheduler_.reset();
}
public:
@@ -63,9 +65,9 @@ class CreateActorBench final : public td::Benchmark {
void run(int n) final {
for (int i = 0; i < n; i++) {
- scheduler_.create_actor_unsafe<TestActor>(0, "TestActor").release();
+ scheduler_->create_actor_unsafe<TestActor>(0, "TestActor").release();
}
- while (scheduler_.run_main(10)) {
+ while (scheduler_->run_main(10)) {
// empty
}
}
@@ -80,7 +82,7 @@ class RingBench final : public td::Benchmark {
int actor_n_ = -1;
int thread_n_ = -1;
td::vector<td::ActorId<PassActor>> actor_array_;
- td::ConcurrentScheduler *scheduler_ = nullptr;
+ td::unique_ptr<td::ConcurrentScheduler> scheduler_;
public:
td::string get_description() const final {
@@ -139,7 +141,7 @@ class RingBench final : public td::Benchmark {
}
void start_up() final {
- scheduler_ = new td::ConcurrentScheduler(thread_n_, 0);
+ scheduler_ = td::make_unique<td::ConcurrentScheduler>(thread_n_, 0);
actor_array_ = td::vector<td::ActorId<PassActor>>(actor_n_);
for (int i = 0; i < actor_n_; i++) {
@@ -163,7 +165,7 @@ class RingBench final : public td::Benchmark {
void tear_down() final {
scheduler_->finish();
- delete scheduler_;
+ scheduler_.reset();
}
};
@@ -244,8 +246,11 @@ class QueryBench final : public td::Benchmark {
td::FutureActor<int> future;
init_promise_future(&promise, &future);
send_closure(client_, &ClientActor::f_immediate_promise, n_, std::move(promise));
- int val = future.move_as_ok();
- CHECK(val == n_ * n_);
+ CHECK(!future.is_ready());
+ CHECK(!future.empty());
+ CHECK(future.get_state() == td::FutureActor<int>::State::Waiting);
+ // int val = future.move_as_ok();
+ // CHECK(val == n_ * n_);
} else if (type == 2) {
td::PromiseActor<int> promise;
init_promise_future(&promise, &future_);
@@ -258,7 +263,7 @@ class QueryBench final : public td::Benchmark {
} else if (type == 4) {
int val = 0;
send_lambda(client_, [&] { val = n_ * n_; });
- CHECK(val == n_ * n_);
+ CHECK(val == 0 || val == n_ * n_);
} else if (type == 5) {
send_closure(client_, &ClientActor::f_promise,
td::PromiseCreator::lambda([actor_id = actor_id(this), n = n_](td::Unit) {
@@ -291,7 +296,7 @@ class QueryBench final : public td::Benchmark {
};
void start_up() final {
- scheduler_ = new td::ConcurrentScheduler(0, 0);
+ scheduler_ = td::make_unique<td::ConcurrentScheduler>(0, 0);
server_ = scheduler_->create_actor_unsafe<ServerActor>(0, "Server");
scheduler_->start();
@@ -311,11 +316,11 @@ class QueryBench final : public td::Benchmark {
void tear_down() final {
server_.release();
scheduler_->finish();
- delete scheduler_;
+ scheduler_.reset();
}
private:
- td::ConcurrentScheduler *scheduler_ = nullptr;
+ td::unique_ptr<td::ConcurrentScheduler> scheduler_;
td::ActorOwn<ServerActor> server_;
};
@@ -330,8 +335,8 @@ int main() {
bench(RingBench<2>(504, 0));
bench(QueryBench<5>());
bench(QueryBench<4>());
- bench(QueryBench<2>());
bench(QueryBench<3>());
+ bench(QueryBench<2>());
bench(QueryBench<1>());
bench(QueryBench<0>());
bench(RingBench<3>(504, 0));
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_crypto.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_crypto.cpp
index 40d7602d2e..98db8cf1e7 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_crypto.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_crypto.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -306,14 +306,14 @@ class AesCbcDecryptBench final : public td::Benchmark {
void start_up() final {
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
- td::Random::secure_bytes(as_slice(key));
- td::Random::secure_bytes(as_slice(iv));
+ td::Random::secure_bytes(as_mutable_slice(key));
+ td::Random::secure_bytes(as_mutable_slice(iv));
}
void run(int n) final {
td::MutableSlice data_slice(data, DATA_SIZE);
for (int i = 0; i < n; i++) {
- td::aes_cbc_decrypt(as_slice(key), as_slice(iv), data_slice, data_slice);
+ td::aes_cbc_decrypt(as_slice(key), as_mutable_slice(iv), data_slice, data_slice);
}
}
};
@@ -330,14 +330,14 @@ class AesCbcEncryptBench final : public td::Benchmark {
void start_up() final {
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
- td::Random::secure_bytes(as_slice(key));
- td::Random::secure_bytes(as_slice(iv));
+ td::Random::secure_bytes(as_mutable_slice(key));
+ td::Random::secure_bytes(as_mutable_slice(iv));
}
void run(int n) final {
td::MutableSlice data_slice(data, DATA_SIZE);
for (int i = 0; i < n; i++) {
- td::aes_cbc_encrypt(as_slice(key), as_slice(iv), data_slice, data_slice);
+ td::aes_cbc_encrypt(as_slice(key), as_mutable_slice(iv), data_slice, data_slice);
}
}
};
@@ -355,8 +355,8 @@ class AesIgeShortBench final : public td::Benchmark {
void start_up() final {
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
- td::Random::secure_bytes(as_slice(key));
- td::Random::secure_bytes(as_slice(iv));
+ td::Random::secure_bytes(as_mutable_slice(key));
+ td::Random::secure_bytes(as_mutable_slice(iv));
}
void run(int n) final {
@@ -367,7 +367,7 @@ class AesIgeShortBench final : public td::Benchmark {
ige.init(as_slice(key), as_slice(iv), false);
ige.decrypt(data_slice, data_slice);
} else {
- td::aes_ige_decrypt(as_slice(key), as_slice(iv), data_slice, data_slice);
+ td::aes_ige_decrypt(as_slice(key), as_mutable_slice(iv), data_slice, data_slice);
}
}
}
@@ -451,7 +451,7 @@ class Crc32Bench final : public td::Benchmark {
alignas(64) unsigned char data[DATA_SIZE];
std::string get_description() const final {
- return PSTRING() << "Crc32 zlib [" << (DATA_SIZE >> 10) << "KB]";
+ return PSTRING() << "CRC32 zlib [" << (DATA_SIZE >> 10) << "KB]";
}
void start_up() final {
@@ -472,7 +472,7 @@ class Crc64Bench final : public td::Benchmark {
alignas(64) unsigned char data[DATA_SIZE];
std::string get_description() const final {
- return PSTRING() << "Crc64 Anton [" << (DATA_SIZE >> 10) << "KB]";
+ return PSTRING() << "CRC64 Anton [" << (DATA_SIZE >> 10) << "KB]";
}
void start_up() final {
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_db.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_db.cpp
index 822a915938..b47fa98bb1 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_db.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_db.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -29,7 +29,7 @@
template <class KeyValueT>
class TdKvBench final : public td::Benchmark {
- td::ConcurrentScheduler sched{1, 0};
+ td::unique_ptr<td::ConcurrentScheduler> scheduler_;
td::string name_;
public:
@@ -72,18 +72,20 @@ class TdKvBench final : public td::Benchmark {
};
void start_up_n(int n) final {
- sched.create_actor_unsafe<Main>(1, "Main", n).release();
+ scheduler_ = td::make_unique<td::ConcurrentScheduler>(1, 0);
+ scheduler_->create_actor_unsafe<Main>(1, "Main", n).release();
}
void run(int n) final {
- sched.start();
- while (sched.run_main(10)) {
+ scheduler_->start();
+ while (scheduler_->run_main(10)) {
// empty
}
- sched.finish();
+ scheduler_->finish();
}
void tear_down() final {
+ scheduler_.reset();
}
};
@@ -184,6 +186,7 @@ class SqliteKeyValueAsyncBench final : public td::Benchmark {
td::string sql_db_name = "testdb.sqlite";
td::SqliteDb::destroy(sql_db_name).ignore();
+ td::SqliteDb::open_with_key(sql_db_name, true, td::DbKey::empty()).move_as_ok();
sql_connection_ = std::make_shared<td::SqliteConnectionSafe>(sql_db_name, td::DbKey::empty());
auto &db = sql_connection_->get();
@@ -229,12 +232,13 @@ class BinlogKeyValueBench final : public td::Benchmark {
int main() {
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(WARNING));
+ bench(TdKvBench<td::BinlogKeyValue<td::Binlog>>("BinlogKeyValue<Binlog>"));
+ bench(TdKvBench<td::BinlogKeyValue<td::ConcurrentBinlog>>("BinlogKeyValue<ConcurrentBinlog>"));
+
bench(BinlogKeyValueBench<true>());
bench(BinlogKeyValueBench<false>());
bench(SqliteKVBench<false>());
bench(SqliteKVBench<true>());
bench(SqliteKeyValueAsyncBench());
- bench(TdKvBench<td::BinlogKeyValue<td::Binlog>>("BinlogKeyValue<Binlog>"));
- bench(TdKvBench<td::BinlogKeyValue<td::ConcurrentBinlog>>("BinlogKeyValue<ConcurrentBinlog>"));
bench(SeqKvBench());
}
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_empty.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_empty.cpp
index ae2068c050..bd51e9f464 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_empty.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_empty.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_handshake.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_handshake.cpp
index f518fe03b0..853da05e3e 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_handshake.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_handshake.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_http.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_http.cpp
index 70fdb909c2..a1ae4f6702 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_http.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_http.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp
index 403af06bec..b4e865ba7a 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_http_server.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_http_server.cpp
index 33cde9ef8c..d41328e2ad 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_http_server.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_http_server.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_http_server_cheat.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_http_server_cheat.cpp
index 8bbd768b40..8fc5abe01f 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_http_server_cheat.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_http_server_cheat.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -11,6 +11,7 @@
#include "td/actor/ConcurrentScheduler.h"
#include "td/utils/buffer.h"
+#include "td/utils/common.h"
#include "td/utils/logging.h"
#include "td/utils/port/detail/PollableFd.h"
#include "td/utils/port/SocketFd.h"
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_http_server_fast.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_http_server_fast.cpp
index 4b140422f1..af23dfc9c5 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_http_server_fast.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_http_server_fast.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_log.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_log.cpp
index 8c2628b8a9..3082350bfb 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_log.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_log.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_misc.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_misc.cpp
index 56a6117bb4..9089890fb9 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_misc.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_misc.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -9,7 +9,6 @@
#include "td/utils/benchmark.h"
#include "td/utils/common.h"
-#include "td/utils/format.h"
#include "td/utils/logging.h"
#include "td/utils/port/Clocks.h"
#include "td/utils/port/EventFd.h"
@@ -228,13 +227,7 @@ class CreateFileBench final : public td::Benchmark {
}
}
void tear_down() final {
- td::walk_path("A/", [&](td::CSlice path, auto type) {
- if (type == td::WalkPath::Type::ExitDir) {
- td::rmdir(path).ignore();
- } else if (type == td::WalkPath::Type::NotDir) {
- td::unlink(path).ignore();
- }
- }).ignore();
+ td::rmrf("A/").ignore();
}
};
@@ -259,13 +252,7 @@ class WalkPathBench final : public td::Benchmark {
}).ignore();
}
void tear_down() final {
- td::walk_path("A/", [&](td::CSlice path, auto type) {
- if (type == td::WalkPath::Type::ExitDir) {
- td::rmdir(path).ignore();
- } else if (type == td::WalkPath::Type::NotDir) {
- td::unlink(path).ignore();
- }
- }).ignore();
+ td::rmrf("A/").ignore();
}
};
@@ -433,13 +420,12 @@ class IdDuplicateCheckerOld {
if (saved_message_ids_.size() == MAX_SAVED_MESSAGE_IDS) {
auto oldest_message_id = *saved_message_ids_.begin();
if (message_id < oldest_message_id) {
- return td::Status::Error(2, PSLICE() << "Ignore very old message_id "
- << td::tag("oldest message_id", oldest_message_id)
- << td::tag("got message_id", message_id));
+ return td::Status::Error(2, PSLICE() << "Ignore very old message " << message_id
+ << " older than the oldest known message " << oldest_message_id);
}
}
if (saved_message_ids_.count(message_id) != 0) {
- return td::Status::Error(1, PSLICE() << "Ignore duplicated message_id " << td::tag("message_id", message_id));
+ return td::Status::Error(1, PSLICE() << "Ignore already processed message " << message_id);
}
saved_message_ids_.insert(message_id);
@@ -463,16 +449,15 @@ class IdDuplicateCheckerNew {
td::Status check(td::int64 message_id) {
auto insert_result = saved_message_ids_.insert(message_id);
if (!insert_result.second) {
- return td::Status::Error(1, PSLICE() << "Ignore duplicated message_id " << td::tag("message_id", message_id));
+ return td::Status::Error(1, PSLICE() << "Ignore already processed message " << message_id);
}
if (saved_message_ids_.size() == MAX_SAVED_MESSAGE_IDS + 1) {
auto begin_it = saved_message_ids_.begin();
bool is_very_old = begin_it == insert_result.first;
saved_message_ids_.erase(begin_it);
if (is_very_old) {
- return td::Status::Error(2, PSLICE() << "Ignore very old message_id "
- << td::tag("oldest message_id", *saved_message_ids_.begin())
- << td::tag("got message_id", message_id));
+ return td::Status::Error(2, PSLICE() << "Ignore very old message " << message_id
+ << " older than the oldest known message " << *saved_message_ids_.begin());
}
}
return td::Status::OK();
@@ -489,16 +474,15 @@ class IdDuplicateCheckerNewOther {
}
td::Status check(td::int64 message_id) {
if (!saved_message_ids_.insert(message_id).second) {
- return td::Status::Error(1, PSLICE() << "Ignore duplicated message_id " << td::tag("message_id", message_id));
+ return td::Status::Error(1, PSLICE() << "Ignore already processed message " << message_id);
}
if (saved_message_ids_.size() == MAX_SAVED_MESSAGE_IDS + 1) {
auto begin_it = saved_message_ids_.begin();
bool is_very_old = *begin_it == message_id;
saved_message_ids_.erase(begin_it);
if (is_very_old) {
- return td::Status::Error(2, PSLICE() << "Ignore very old message_id "
- << td::tag("oldest message_id", *saved_message_ids_.begin())
- << td::tag("got message_id", message_id));
+ return td::Status::Error(2, PSLICE() << "Ignore very old message " << message_id
+ << " older than the oldest known message " << *saved_message_ids_.begin());
}
}
return td::Status::OK();
@@ -517,14 +501,14 @@ class IdDuplicateCheckerNewSimple {
td::Status check(td::int64 message_id) {
auto insert_result = saved_message_ids_.insert(message_id);
if (!insert_result.second) {
- return td::Status::Error(1, "Ignore duplicated message_id");
+ return td::Status::Error(1, "Ignore already processed message");
}
if (saved_message_ids_.size() == MAX_SAVED_MESSAGE_IDS + 1) {
auto begin_it = saved_message_ids_.begin();
bool is_very_old = begin_it == insert_result.first;
saved_message_ids_.erase(begin_it);
if (is_very_old) {
- return td::Status::Error(2, "Ignore very old message_id");
+ return td::Status::Error(2, "Ignore very old message");
}
}
return td::Status::OK();
@@ -552,13 +536,12 @@ class IdDuplicateCheckerArray {
return td::Status::OK();
}
if (end_pos_ >= max_size && message_id < saved_message_ids_[0]) {
- return td::Status::Error(2, PSLICE() << "Ignore very old message_id "
- << td::tag("oldest message_id", saved_message_ids_[0])
- << td::tag("got message_id", message_id));
+ return td::Status::Error(2, PSLICE() << "Ignore very old message " << message_id
+ << " older than the oldest known message " << saved_message_ids_[0]);
}
auto it = std::lower_bound(&saved_message_ids_[0], &saved_message_ids_[end_pos_], message_id);
if (*it == message_id) {
- return td::Status::Error(1, PSLICE() << "Ignore duplicated message_id " << td::tag("message_id", message_id));
+ return td::Status::Error(1, PSLICE() << "Ignore already processed message " << message_id);
}
std::copy_backward(it, &saved_message_ids_[end_pos_], &saved_message_ids_[end_pos_ + 1]);
*it = message_id;
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_queue.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_queue.cpp
index 6f7cf20bc9..c28554c757 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_queue.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_queue.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -859,8 +859,8 @@ static void test_queue() {
for (size_t i = 0; i < THREAD_COUNT; i++) {
threads.emplace_back([&q = queues[i]] {
while (true) {
- auto got = q.reader_wait_nonblock();
- while (got-- > 0) {
+ auto ready_count = q.reader_wait_nonblock();
+ while (ready_count-- > 0) {
q.reader_get_unsafe();
}
q.reader_get_event_fd().wait(1000);
@@ -888,7 +888,6 @@ int main() {
#endif
#if TD_PORT_POSIX
- // TODO: yield makes it extremely slow. Yet some backoff may be necessary.
// td::bench(RingBenchmark<SemQueue>());
// td::bench(RingBenchmark<td::PollQueue<qvalue_t>>());
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_tddb.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_tddb.cpp
index c3298327e5..a2c4a80d32 100644
--- a/protocols/Telegram/tdlib/td/benchmark/bench_tddb.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/bench_tddb.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/benchmark/check_proxy.cpp b/protocols/Telegram/tdlib/td/benchmark/check_proxy.cpp
index 0a54c598c0..dcf49b5976 100644
--- a/protocols/Telegram/tdlib/td/benchmark/check_proxy.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/check_proxy.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/benchmark/check_tls.cpp b/protocols/Telegram/tdlib/td/benchmark/check_tls.cpp
index f7fb1fecb7..7b779dfdd0 100644
--- a/protocols/Telegram/tdlib/td/benchmark/check_tls.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/check_tls.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/benchmark/hashmap_build.cpp b/protocols/Telegram/tdlib/td/benchmark/hashmap_build.cpp
index f6e71b748a..c536ab6020 100644
--- a/protocols/Telegram/tdlib/td/benchmark/hashmap_build.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/hashmap_build.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/benchmark/hashset_memory.cpp b/protocols/Telegram/tdlib/td/benchmark/hashset_memory.cpp
index 8f31b52114..18b9cd940c 100644
--- a/protocols/Telegram/tdlib/td/benchmark/hashset_memory.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/hashset_memory.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/benchmark/rmdir.cpp b/protocols/Telegram/tdlib/td/benchmark/rmdir.cpp
index d61baa0a02..ffc51828f4 100644
--- a/protocols/Telegram/tdlib/td/benchmark/rmdir.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/rmdir.cpp
@@ -1,9 +1,10 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
+#include "td/utils/common.h"
#include "td/utils/logging.h"
#include "td/utils/port/path.h"
#include "td/utils/Slice.h"
@@ -17,8 +18,23 @@ int main(int argc, char *argv[]) {
auto status = td::walk_path(dir, [&](td::CSlice path, auto type) {
if (type != td::WalkPath::Type::EnterDir) {
cnt++;
- LOG(INFO) << path << " " << (type == td::WalkPath::Type::ExitDir);
}
+ auto type_name = [&] {
+ switch (type) {
+ case td::WalkPath::Type::EnterDir:
+ return td::CSlice("Open");
+ case td::WalkPath::Type::ExitDir:
+ return td::CSlice("Exit");
+ case td::WalkPath::Type::RegularFile:
+ return td::CSlice("File");
+ case td::WalkPath::Type::Symlink:
+ return td::CSlice("Link");
+ default:
+ UNREACHABLE();
+ return td::CSlice();
+ }
+ }();
+ LOG(INFO) << type_name << ' ' << path;
//if (is_dir) {
// td::rmdir(path);
//} else {
diff --git a/protocols/Telegram/tdlib/td/benchmark/wget.cpp b/protocols/Telegram/tdlib/td/benchmark/wget.cpp
index 5145f317f1..f29e02c1e1 100644
--- a/protocols/Telegram/tdlib/td/benchmark/wget.cpp
+++ b/protocols/Telegram/tdlib/td/benchmark/wget.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)