Date: Sun, 6 Apr 2014 00:11:51 +0400 From: Dmitry Sivachenko <trtrmitya@gmail.com> To: John Baldwin <jhb@FreeBSD.org> Cc: freebsd-hackers@freebsd.org, =?utf-8?Q?Trond_Endrest=C3=B8l?= <Trond.Endrestol@fagskolen.gjovik.no> Subject: Re: madvise() vs posix_fadvise() Message-ID: <8DAE3175-FE32-4D17-A386-063DDB6C45F7@gmail.com> In-Reply-To: <5426E303-E35B-4D4A-AB62-3571228A5A2C@gmail.com> References: <D6BD48AF-9522-495D-8D54-37854E53C272@gmail.com> <201404031102.38598.jhb@freebsd.org> <EF134BCA-1E92-4C98-8763-9A31EA96839A@gmail.com> <201404041612.35889.jhb@freebsd.org> <5426E303-E35B-4D4A-AB62-3571228A5A2C@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 05 =D0=B0=D0=BF=D1=80. 2014 =D0=B3., at 1:02, Dmitry Sivachenko = <trtrmitya@gmail.com> wrote: > On 05 =D0=B0=D0=BF=D1=80. 2014 =D0=B3., at 0:12, John Baldwin = <jhb@FreeBSD.org> wrote: >=20 >>=20 >> MADV_WILLNEED is not going to give you what you want. OTOH, if you = haven't >> tried FreeBSD 10 yet, I would suggest trying that. There have been = changes >> to pagedaemon that might make it do a better job of kicking out the = pages >> of the log files automatically. >>=20 >=20 >=20 > I did. My situation became worse after I moved from stable/9 to = stable/10. > My feeling is that stable/10 pushes rarely used mmaped pages out of = RAM more aggressively than stable/9 did. >=20 > For now, the only solution I found is doing msync(MS_INVALIDATE) on = log files after gzipping and after backup via rsync. > This moves corresponding memory pages from Inactive to Free and = prevents system to occupy all free memory with cached log files and to = purge mmaped data out of RAM to accomodate more disk cache. >=20 > What I would love to see is an ability to tell OS not to release = mmaped data unless "really needed" (disk cache is not an excuse). One more observation as it seems to be related. If my program allocates RAM via malloc() rather than mmap(), I see that = VM swaps rarely used parts of malloced data out as disk is being used (more and more memory goes to Inactive with cached files content). This is also different from stable/9 and seems not good. Why to keep = cached content of files forever? (seems there is no timeout for keeping = cached files content in Inactive state). So after few days of uptime = all available RAM is either in Active state with frequently used pages = of running processes or in Inactive state with cached files data. = Rarely used parts of processes memory goes to swap.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8DAE3175-FE32-4D17-A386-063DDB6C45F7>