Minor fixes.

GitOrigin-RevId: ce9058c2075281697cc41de2ab970dd11e189f77
This commit is contained in:
levlam 2020-06-13 05:13:11 +03:00
parent c68481052a
commit 2ed9cb3b75
5 changed files with 15 additions and 17 deletions

View File

@ -257,7 +257,7 @@ class FileDb : public FileDbInterface {
while (true) { while (true) {
if (attempt_count > 100) { if (attempt_count > 100) {
LOG(FATAL) << "Cycle in file database? current_pmc_id=" << current_pmc_id << " key=" << key LOG(FATAL) << "Cycle in file database? current_pmc_id=" << current_pmc_id << " key=" << key
<< " links=" << td::format::as_array(ids); << " links=" << format::as_array(ids);
} }
attempt_count++; attempt_count++;

View File

@ -17,9 +17,9 @@
#include "td/utils/Random.h" #include "td/utils/Random.h"
#include "td/utils/StorerBase.h" #include "td/utils/StorerBase.h"
#include "td/utils/Time.h" #include "td/utils/Time.h"
#include "td/utils/tl_helpers.h"
#include "td/utils/tl_parsers.h" #include "td/utils/tl_parsers.h"
#include "td/utils/tl_storers.h" #include "td/utils/tl_storers.h"
#include "td/utils/tl_helpers.h"
#include "td/utils/VectorQueue.h" #include "td/utils/VectorQueue.h"
#include <algorithm> #include <algorithm>
@ -97,7 +97,6 @@ class TQueueImpl : public TQueue {
} }
bool do_push(QueueId queue_id, RawEvent &&raw_event) override { bool do_push(QueueId queue_id, RawEvent &&raw_event) override {
// LOG(ERROR) << "Push to queue " << queue_id << " " << raw_event.event_id;
CHECK(raw_event.event_id.is_valid()); CHECK(raw_event.event_id.is_valid());
auto &q = queues_[queue_id]; auto &q = queues_[queue_id];
if (q.events.empty() || q.events.back().event_id < raw_event.event_id) { if (q.events.empty() || q.events.back().event_id < raw_event.event_id) {
@ -192,7 +191,6 @@ class TQueueImpl : public TQueue {
Result<size_t> get(QueueId queue_id, EventId from_id, bool forget_previous, double now, Result<size_t> get(QueueId queue_id, EventId from_id, bool forget_previous, double now,
MutableSpan<Event> &result_events) override { MutableSpan<Event> &result_events) override {
// LOG(ERROR) << "Get " << queue_id << " " << from_id;
auto it = queues_.find(queue_id); auto it = queues_.find(queue_id);
if (it == queues_.end()) { if (it == queues_.end()) {
result_events.truncate(0); result_events.truncate(0);
@ -220,7 +218,6 @@ class TQueueImpl : public TQueue {
[](auto &event, EventId event_id) { return event.event_id < event_id; }) - [](auto &event, EventId event_id) { return event.event_id < event_id; }) -
from_events.begin(); from_events.begin();
} }
// LOG(ERROR) << tag("first_i", first_i) << tag("size", from_events.size());
for (i = first_i; i < from_events.size(); i++) { for (i = first_i; i < from_events.size(); i++) {
auto &from = from_events[i]; auto &from = from_events[i];
try_pop(queue_id, from, forget_previous ? from_id : EventId{}, q.tail_id, now); try_pop(queue_id, from, forget_previous ? from_id : EventId{}, q.tail_id, now);
@ -285,8 +282,6 @@ class TQueueImpl : public TQueue {
} }
void try_pop(QueueId queue_id, RawEvent &event, EventId from_id, EventId tail_id, double now) { void try_pop(QueueId queue_id, RawEvent &event, EventId from_id, EventId tail_id, double now) {
// LOG(ERROR) << event.expires_at << " < " << now << " = " << (event.expires_at < now) << " "
// << (event.event_id < from_id) << " " << event.data.empty();
if (event.expires_at < now || event.event_id < from_id || event.data.empty()) { if (event.expires_at < now || event.event_id < from_id || event.data.empty()) {
pop(queue_id, event, tail_id); pop(queue_id, event, tail_id);
} }
@ -299,7 +294,6 @@ class TQueueImpl : public TQueue {
return; return;
} }
// LOG(ERROR) << "Drop " << queue_id << " " << event.event_id;
if (event.event_id.next().ok() == tail_id) { if (event.event_id.next().ok() == tail_id) {
if (!event.data.empty()) { if (!event.data.empty()) {
event.data = {}; event.data = {};

View File

@ -167,7 +167,7 @@ int Random::Xorshift128plus::fast(int min, int max) {
void Random::Xorshift128plus::bytes(MutableSlice dest) { void Random::Xorshift128plus::bytes(MutableSlice dest) {
int cnt = 0; int cnt = 0;
td::uint64 buf = 0; uint64 buf = 0;
for (auto &c : dest) { for (auto &c : dest) {
if (cnt == 0) { if (cnt == 0) {
buf = operator()(); buf = operator()();

View File

@ -197,7 +197,7 @@ class HashMapBenchmark : public td::Benchmark {
return HashMap::get_name(); return HashMap::get_name();
} }
void start_up_n(int n) override { void start_up_n(int n) override {
n *= (int)threads_n; n *= static_cast<int>(threads_n);
n_ = n; n_ = n;
hash_map = td::make_unique<HashMap>(n * 2); hash_map = td::make_unique<HashMap>(n * 2);
} }

View File

@ -66,17 +66,21 @@ static void do_run_list_test(ListRootT &root, std::atomic<td::uint64> &id) {
nodes.emplace_back(NodeT({next_id(), false})); nodes.emplace_back(NodeT({next_id(), false}));
}; };
auto pop_node = [&] { auto pop_node = [&] {
if (nodes.size() == 0) { if (nodes.empty()) {
return; return;
} }
nodes.pop_back(); nodes.pop_back();
}; };
auto random_node_index = [&] {
CHECK(!nodes.empty());
return rnd.fast(0, static_cast<int>(nodes.size()) - 1);
};
auto link_node = [&] { auto link_node = [&] {
if (nodes.empty()) { if (nodes.empty()) {
return; return;
} }
auto i = rnd.fast(0, (int)nodes.size() - 1); auto i = random_node_index();
nodes[i].remove(); nodes[i].remove();
get_data(nodes[i]) = ListData(next_id(), true); get_data(nodes[i]) = ListData(next_id(), true);
root.put(&nodes[i]); root.put(&nodes[i]);
@ -85,7 +89,7 @@ static void do_run_list_test(ListRootT &root, std::atomic<td::uint64> &id) {
if (nodes.empty()) { if (nodes.empty()) {
return; return;
} }
auto i = rnd.fast(0, (int)nodes.size() - 1); auto i = random_node_index();
nodes[i].remove(); nodes[i].remove();
get_data(nodes[i]).in_list = false; get_data(nodes[i]).in_list = false;
}; };
@ -93,16 +97,16 @@ static void do_run_list_test(ListRootT &root, std::atomic<td::uint64> &id) {
if (nodes.empty()) { if (nodes.empty()) {
return; return;
} }
auto i = rnd.fast(0, (int)nodes.size() - 1); auto i = random_node_index();
auto j = rnd.fast(0, (int)nodes.size() - 1); auto j = random_node_index();
std::swap(nodes[i], nodes[j]); std::swap(nodes[i], nodes[j]);
}; };
auto set_node = [&] { auto set_node = [&] {
if (nodes.empty()) { if (nodes.empty()) {
return; return;
} }
auto i = rnd.fast(0, (int)nodes.size() - 1); auto i = random_node_index();
auto j = rnd.fast(0, (int)nodes.size() - 1); auto j = random_node_index();
nodes[i] = std::move(nodes[j]); nodes[i] = std::move(nodes[j]);
}; };
auto validate = [&] { auto validate = [&] {