From 69adae5168da231c6cf319f708860954701b25ed Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Wed, 3 Dec 2014 18:25:44 +0100 Subject: journal: replace contexts hashmap with a plain array try_context() is such a hot path that the hashmap lookup is expensive. The number of contexts is small - it is the number of object types. Using a hashmap is overkill. A plain array will do. Before: $ time ./journalctl --since=2014-06-01 --until=2014-07-01 > /dev/null real 0m9.445s user 0m9.228s sys 0m0.213s After: $ time ./journalctl --since=2014-06-01 --until=2014-07-01 > /dev/null real 0m5.438s user 0m5.266s sys 0m0.170s --- src/journal/journal-file.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/journal/journal-file.c') diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index 82e50fcca4..7cdaf2920b 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -376,6 +376,7 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) static unsigned type_to_context(ObjectType type) { /* One context for each type, plus one catch-all for the rest */ + assert_cc(_OBJECT_TYPE_MAX <= MMAP_CACHE_MAX_CONTEXTS); return type > OBJECT_UNUSED && type < _OBJECT_TYPE_MAX ? type : 0; } -- cgit v1.2.3-54-g00ecf