# drop_caches does not work completely. (Resolved)

## slackeast

I have a process with multiple OLAP databases running at the same time that was IO bound.  So I created a large tmpfs where the database files reside.   It greatly improved performance.   However, once the linux filesystem cache fills up and there is no available free memory, the process slows down even worse than before.   The kernel can't free up the cache fast enough.  So I started to drop_caches using the commands:

 *Quote:*   

> sync
> 
> echo >3 /proc/sys/vm/drop_caches
> 
> echo >1 /proc/sys/vm/drop_caches
> ...

 

This freed up some of the memory but not all.   Why would this be so?  here is free -g.  

```
             total       used       free     shared    buffers     cached

Mem:          1009        869        140          0          0         31

-/+ buffers/cache:        838        171

Swap:           96          0         96

```

Here is cat /proc/meminfo

 *Quote:*   

> MemTotal:       1058964444 kB
> 
> MemFree:        147198688 kB
> 
> Buffers:            8112 kB
> ...

 

I would really like to disable the filesystem cache because all the important files exist on the large tmpfs.   It doesn't sound like I can do that so I would at least like to clear out the entire 'cache' with drop_caches.   Any ideas why I can't?

Thanks in advance.Last edited by slackeast on Fri May 24, 2013 7:54 pm; edited 1 time in total

----------

## BradN

tmpfs is backed by filesystem cache, if you clear it completely then all tmpfs is gone.

----------

## slackeast

Oh I should clarify, by tmpfs, I mounted a tmpfs in fstab.   Like.

```
olapdisk               /u01/  tmpfs   defaults,size=750g  0 0

```

[/quote]

----------

## BradN

Right, see here:  https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt

 *Quote:*   

> Since tmpfs lives completely in the page cache and on swap, all tmpfs
> 
> pages currently in memory will show up as cached. It will not show up
> 
> as shared or something like that. Further on you can check the actual
> ...

 

As to your performance problem, I don't know really what is causing this.  There are some tunable parameters, see http://www.westnet.com/~gsmith/content/linux-pdflush.htm for some explanations.  It's 6 year old documentation though, maybe there's something better.

Maybe some of your tmpfs is getting pushed to swap in order to make more room for other filesystem cache, I could see this really screwing up performance.  Try to monitor what exactly happens in memory sizes as the performance goes to crap, maybe you can get some clues as to what could be triggering then.

----------

## slackeast

OK, we resolved.   I guess the server had HugePages configured.

HugePages_Total: 410200 

HugePages_Free: 410200 

HugePages_Rsvd: 0 

HugePages_Surp: 0 

Hugepagesize: 2048 kB 

It was locking up all the ram causing contention issues.   We got rid of it and we no longer have issues!

Thanks for the help.

----------

