chiark / gitweb /
journal: optimize iteration: skip files that cannot improve current candidate entry
authorMichal Schmidt <mschmidt@redhat.com>
Tue, 9 Dec 2014 19:27:26 +0000 (20:27 +0100)
committerMichal Schmidt <mschmidt@redhat.com>
Tue, 9 Dec 2014 20:45:11 +0000 (21:45 +0100)
commitf8b5a3b75fb55f0acb85c21424b3893c822742e9
tree46579d628e31c0be4f3d4c9e179afd958a503f0b
parentb7c88ab8cc7d55a43450bf3dea750f95f2e910d6
journal: optimize iteration: skip files that cannot improve current candidate entry

Suppose that while iterating we have already looked into a journal file
and got a candidate for the next entry. And we are considering to look
into another journal file because it may contain an entry that is nearer
to the current location than the candidate.

We should skip the whole journal file if we can tell by looking at its
header that none of its entries can precede the candidate.

Before:
$ time ./journalctl --since=2014-06-01 --until=2014-07-01 > /dev/null

real    0m20.518s
user    0m19.989s
sys     0m0.328s

After:
$ time ./journalctl --since=2014-06-01 --until=2014-07-01 > /dev/null

real    0m9.445s
user    0m9.228s
sys     0m0.213s
src/journal/sd-journal.c