journal: limit the number of entries in the cache based on available memory
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 22 Jan 2019 15:12:52 +0000 (16:12 +0100)
committerLukáš Nykrýn <lnykryn@redhat.com>
Thu, 7 Feb 2019 11:57:43 +0000 (12:57 +0100)
commitde72fa6b0582b95216215cc1400412fe91bc8ba3
treea1352a8d6277c5b806c41ee81095703265859779
parentee14a2bd3d95b5d15e4d72ee2582b366e5009a86
journal: limit the number of entries in the cache based on available memory

This is far from perfect, but should give mostly reasonable values. My
assumption is that if somebody has a few hundred MB of memory, they are
unlikely to have thousands of processes logging. A hundred would already be a
lot. So let's scale the cache size propritionally to the total memory size,
with clamping on both ends.

The formula gives 64 cache entries for each GB of RAM.

(cherry-picked from commit b12a480829c5ca8f4d4fa9cde8716b5f2f12a3ad)

Related: #1664976
src/journal/journald-context.c