Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what are pagecache, dentries, inodes?

Just learned these 3 new techniques from https://unix.stackexchange.com/questions/87908/how-do-you-empty-the-buffers-and-cache-on-a-linux-system:


To free pagecache:

# echo 1 > /proc/sys/vm/drop_caches 

To free dentries and inodes:

# echo 2 > /proc/sys/vm/drop_caches 

To free pagecache, dentries and inodes:

# echo 3 > /proc/sys/vm/drop_caches 

I am trying to understand what exactly are pagecache, dentries and inodes. What exactly are they?

Do freeing them up also remove the useful memcached and/or redis cache?

--

Why i am asking this question? My Amazon EC2 server RAM was getting filled up over the days - from 6% to up to 95% in a matter of 7 days. I am having to run a bi-weekly cronjob to remove these cache. Then memory usage drops to 6% again.

like image 713
Rakib Avatar asked Apr 25 '15 19:04

Rakib


People also ask

Which command below will clear the PageCache Dentries and inodes?

The command used in this method uses the "echo 3 >" which cleans the PageCache, dentries, and inodes at the same time. Command: # sync ; echo 3 > / porc / sys / vm / drop_caches.

What is inode cache?

A memory-resident inode is used whenever an operation is performed on an entity in the file system. The inode read from disk is cached in case it is needed again. ufs_ninode is the size that the UNIX file system attempts to keep the list of idle inodes.

Is inode cached in page cache?

A page does not necessarily contain physically adjacent disk blocks, and it cannot thus be identified by a device number and a block number. Instead, a page in the page cache is identified by a file's inode and by the offset within the file.

What is a Dentry in Linux?

A dentry (short for "directory entry") is what the Linux kernel uses to keep track of the hierarchy of files in directories. Each dentry maps an inode number to a file name and a parent directory.


1 Answers

With some oversimplification, let me try to explain in what appears to be the context of your question because there are multiple answers.

It appears you are working with memory caching of directory structures. An inode in your context is a data structure that represents a file. A dentries is a data structure that represents a directory. These structures could be used to build a memory cache that represents the file structure on a disk. To get a directly listing, the OS could go to the dentries--if the directory is there--list its contents (a series of inodes). If not there, go to the disk and read it into memory so that it can be used again.

The page cache could contain any memory mappings to blocks on disk. That could conceivably be buffered I/O, memory mapped files, paged areas of executables--anything that the OS could hold in memory from a file.

Your commands flush these buffers.

like image 102
user3344003 Avatar answered Oct 02 '22 11:10

user3344003