]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/journal/journal-file.c
journal: avoid unnecessary mmap_cache_get() calls 6355/head
authorVito Caputo <vcaputo@pengaru.com>
Thu, 13 Jul 2017 05:17:06 +0000 (22:17 -0700)
committerVito Caputo <vcaputo@pengaru.com>
Thu, 13 Jul 2017 06:59:29 +0000 (23:59 -0700)
commitb439282e0b496923cb144954cd479949fff3aa01
treef0a723df2fe4139b2a955c883663fe0d1f8c62db
parentb42549ad69ab51789d5b8fa9f1dfc6c2fe45f43e
journal: avoid unnecessary mmap_cache_get() calls

journal_file_move_to_object() can skip the second
journal_file_move_to() call if the first one already mapped a
sufficiently large area.

Now that mmap_cache_get() returns the size of the mapped area
when asked, ask for the size and only perform the second call if
the required size exceeds the mapped size instead of the object
header size.

This results in a nice performance boost in my testing, even with
a corpus of many small logs burning much CPU time elsewhere:

 Before:

  # time ./journalctl -b -1 --no-pager > /dev/null
  real    0m16.330s
  user    0m16.281s
  sys     0m0.046s

  # time ./journalctl -b -1 --no-pager > /dev/null
  real    0m16.409s
  user    0m16.358s
  sys     0m0.048s

  # time ./journalctl -b -1 --no-pager > /dev/null
  real    0m16.625s
  user    0m16.558s
  sys     0m0.061s

 After:

  # time ./journalctl -b -1 --no-pager > /dev/null
  real    0m15.311s
  user    0m15.257s
  sys     0m0.046s

  # time ./journalctl -b -1 --no-pager > /dev/null
  real    0m15.201s
  user    0m15.135s
  sys     0m0.062s

  # time ./journalctl -b -1 --no-pager > /dev/null
  real    0m15.170s
  user    0m15.113s
  sys     0m0.053s
src/journal/journal-file.c