1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-26 14:04:03 +03:00

mmap-cache: add some stats about files/windows/unused

Let's give some visibility into the ratio of files:windows:unused
by the time we're done using the cache.

(cherry picked from commit 284802c597aa0194dc1504db65ee24941d9721eb)
This commit is contained in:
Vito Caputo 2024-09-21 14:43:51 -07:00 committed by Luca Boccassi
parent 3dcde32fed
commit 5e45c58274
2 changed files with 7 additions and 5 deletions

View File

@ -435,8 +435,8 @@ found:
void mmap_cache_stats_log_debug(MMapCache *m) {
assert(m);
log_debug("mmap cache statistics: %u category cache hit, %u window list hit, %u miss",
m->n_category_cache_hit, m->n_window_list_hit, m->n_missed);
log_debug("mmap cache statistics: %u category cache hit, %u window list hit, %u miss, %u files, %u windows, %u unused",
m->n_category_cache_hit, m->n_window_list_hit, m->n_missed, hashmap_size(m->fds), m->n_windows, m->n_unused);
}
static void mmap_cache_process_sigbus(MMapCache *m) {

View File

@ -2476,6 +2476,10 @@ _public_ void sd_journal_close(sd_journal *j) {
sd_journal_flush_matches(j);
/* log stats before closing files so we can see the windows state */
if (j->mmap)
mmap_cache_stats_log_debug(j->mmap);
ordered_hashmap_free_with_destructor(j->files, journal_file_close);
iterated_cache_free(j->files_cache);
@ -2487,10 +2491,8 @@ _public_ void sd_journal_close(sd_journal *j) {
safe_close(j->inotify_fd);
if (j->mmap) {
mmap_cache_stats_log_debug(j->mmap);
if (j->mmap)
mmap_cache_unref(j->mmap);
}
hashmap_free_free(j->errors);