Browse Source

[Minor] Properly print top symbols by timeout

tags/3.3
Vsevolod Stakhov 1 year ago
parent
commit
e49a9382be
No account linked to committer's email address

+ 1
- 1
src/libserver/symcache/symcache_c.cxx View File

@@ -265,7 +265,7 @@ rspamd_symcache_item_name(struct rspamd_symcache_item *item)
auto *real_item = C_API_SYMCACHE_ITEM(item);

if (real_item == nullptr) {
return 0;
return nullptr;
}

return real_item->get_name().c_str();

+ 2
- 2
src/libserver/symcache/symcache_impl.cxx View File

@@ -1215,7 +1215,7 @@ auto symcache::get_max_timeout(std::vector<std::pair<double, const cache_item *>
auto max_timeout = 0.0, added_timeout = 0.0;
const cache_item *max_elt = nullptr;
for (const auto &it : vec) {
if (it->priority != saved_priority) {
if (it->priority != saved_priority && max_elt != nullptr && max_timeout > 0) {
accumulated_timeout += max_timeout;
added_timeout += max_timeout;
msg_debug_cache_lambda("added %.2f to the timeout (%.2f) as the priority has changed (%d -> %d);"
@@ -1276,7 +1276,7 @@ auto symcache::get_max_timeout(std::vector<std::pair<double, const cache_item *>
/* Sort in decreasing order by timeout */
std::stable_sort(std::begin(elts), std::end(elts),
[](const auto &p1, const auto &p2) {
return p2.first > p1.first;
return p1.first > p2.first;
});

msg_debug_cache("overall cache timeout: %.2f, %.2f from prefilters,"

+ 23
- 7
src/libserver/worker_util.c View File

@@ -960,8 +960,6 @@ rspamd_main_heartbeat_start (struct rspamd_worker *wrk, struct ev_loop *event_lo
static bool
rspamd_maybe_reuseport_socket (struct rspamd_worker_listen_socket *ls)
{
gint nfd = -1;

if (ls->is_systemd) {
/* No need to reuseport */
return true;
@@ -978,6 +976,7 @@ rspamd_maybe_reuseport_socket (struct rspamd_worker_listen_socket *ls)
}

#if defined(SO_REUSEPORT) && defined(SO_REUSEADDR) && defined(LINUX)
gint nfd = -1;

if (ls->type == RSPAMD_WORKER_SOCKET_UDP) {
nfd = rspamd_inet_address_listen (ls->addr,
@@ -1005,8 +1004,6 @@ rspamd_maybe_reuseport_socket (struct rspamd_worker_listen_socket *ls)
*/
nfd = ls->fd;
}
#else
nfd = ls->fd;
#endif

#if 0
@@ -2240,9 +2237,28 @@ rspamd_worker_check_and_adjust_timeout (struct rspamd_config *cfg, gdouble timeo
g_assert (tres != 0);

if (tres->max_timeout > timeout) {
msg_info_config("configured task_timeout %.2f is less than maximum symbols cache timeout %.2f, so"
"some symbols could be terminated early", timeout, tres->max_timeout);
/* TODO: list timeouts for top symbols */
msg_info_config("configured task_timeout %.2f is less than maximum symbols cache timeout %.2f; "
"some symbols can be terminated before checks", timeout, tres->max_timeout);
GString *buf = g_string_sized_new(512);
static const int max_displayed_items = 12;

for (int i = 0; i < MIN(tres->nitems, max_displayed_items); i++) {
if (i == 0) {
rspamd_printf_gstring(buf, "%s(%.2f)",
rspamd_symcache_item_name((struct rspamd_symcache_item *)tres->items[i].item),
tres->items[i].timeout);
}
else {
rspamd_printf_gstring(buf, "; %s(%.2f)",
rspamd_symcache_item_name((struct rspamd_symcache_item *)tres->items[i].item),
tres->items[i].timeout);
}
}
msg_info_config("list of top %d symbols by execution time: %v",
MIN(tres->nitems, max_displayed_items),
buf);

g_string_free(buf, TRUE);
}

rspamd_symcache_timeout_result_free (tres);

Loading…
Cancel
Save