chiark / gitweb /
journal: replace contexts hashmap with a plain array
authorMichal Schmidt <mschmidt@redhat.com>
Wed, 3 Dec 2014 17:25:44 +0000 (18:25 +0100)
committerMichal Schmidt <mschmidt@redhat.com>
Fri, 12 Dec 2014 23:47:23 +0000 (00:47 +0100)
commit69adae5168da231c6cf319f708860954701b25ed
treea682223e1a24f70b2befef8d678a545b0746a889
parent634ed0ee3466e5e5f78d3acbe9782650ff456288
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
src/journal/mmap-cache.c
src/journal/mmap-cache.h