diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2014-12-18 14:21:55 +0100 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2014-12-18 14:29:46 +0100 |
commit | 6e693b42dcb0b332364b0414107826826925c49f (patch) | |
tree | 9a518765de829bafb6197f3af15ba4b1e6e605a3 /src/journal/sd-journal.c | |
parent | 58439db4cc45a6f84a74ad73f873bd3c113eebf6 (diff) |
journal: optimize iteration by skipping exhausted files
If from a previous iteration we know we are at the end of a journal
file, don't bother looking into the file again. This is complicated by
the fact that the EOF does not have to be permanent (think of
"journalctl -f"). So we also check if the number of entries in the
journal file changed.
This optimization has a similar effect as "journal: optimize iteration:
skip whole files behind current location" had.
Diffstat (limited to 'src/journal/sd-journal.c')
-rw-r--r-- | src/journal/sd-journal.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index f3aae9b0ed..0aaf2257d4 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -729,12 +729,18 @@ static int next_with_matches( static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direction) { Object *c; - uint64_t cp; + uint64_t cp, n_entries; int r; assert(j); assert(f); + /* If we hit EOF before, recheck if any new entries arrived. */ + n_entries = le64toh(f->header->n_entries); + if (f->location_type == LOCATION_TAIL && n_entries == f->last_n_entries) + return 0; + f->last_n_entries = n_entries; + if (f->last_direction == direction && f->current_offset > 0) { cp = f->current_offset; |