mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-11-27 06:26:50 +01:00
Store separate size of query_list_.
This commit is contained in:
parent
eafb9375d2
commit
60acf1e402
@ -32,6 +32,7 @@ struct SharedData {
|
||||
std::atomic<int> next_verbosity_level_{-1};
|
||||
|
||||
// not thread-safe
|
||||
size_t query_list_size_ = 0;
|
||||
td::ListNode query_list_;
|
||||
td::unique_ptr<td::KeyValueSyncInterface> webhook_db_;
|
||||
td::unique_ptr<td::TQueue> tqueue_;
|
||||
|
@ -47,6 +47,7 @@ Query::Query(td::vector<td::BufferSlice> &&container, td::Slice token, bool is_t
|
||||
if (shared_data_) {
|
||||
shared_data_->query_count_++;
|
||||
if (method_ != "getupdates") {
|
||||
shared_data_->query_list_size_++;
|
||||
shared_data_->query_list_.put(this);
|
||||
}
|
||||
}
|
||||
|
@ -110,6 +110,9 @@ class Query : public td::ListNode {
|
||||
~Query() {
|
||||
if (shared_data_) {
|
||||
shared_data_->query_count_--;
|
||||
if (!empty()) {
|
||||
shared_data_->query_list_size_--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,13 +144,14 @@ static void dump_statistics(const std::shared_ptr<SharedData> &shared_data,
|
||||
LOG(WARNING) << td::tag("buffer_mem", td::format::as_size(td::BufferAllocator::get_buffer_mem()));
|
||||
LOG(WARNING) << td::tag("buffer_slice_size", td::format::as_size(td::BufferAllocator::get_buffer_slice_size()));
|
||||
|
||||
auto query_list_size = shared_data->query_list_size_;
|
||||
auto query_count = shared_data->query_count_.load();
|
||||
LOG(WARNING) << td::tag("pending queries", query_count);
|
||||
LOG(WARNING) << td::tag("pending queries", query_count) << td::tag("pending requests", query_list_size);
|
||||
|
||||
td::uint64 i = 0;
|
||||
bool was_gap = false;
|
||||
for (auto end = &shared_data->query_list_, cur = end->prev; cur != end; cur = cur->prev, i++) {
|
||||
if (i < 20 || i > query_count - 20 || i % (query_count / 50 + 1) == 0) {
|
||||
if (i < 20 || i > query_list_size - 20 || i % (query_list_size / 50 + 1) == 0) {
|
||||
if (was_gap) {
|
||||
LOG(WARNING) << "...";
|
||||
was_gap = false;
|
||||
|
Loading…
Reference in New Issue
Block a user