SlideShare a Scribd company logo
Memory
+ Memory Management
Linux Kernel Memory Management
( https://www.kernel.org/doc/Documentation/vm/ )
Linux uses Virtual Memory to manage the
address space of the entire OS
VM extends the size of the physical memory
All OS processes 'live' in the VM and can
occasionally be relocated due to the kernel
demand
+ Memory Management
Linux Kernel Memory Management
Memory Manager Unit (MMU) is an
implementation of a hardware object
( in the CPU ) which manages the VM
Translation Lookaside Buffer (TLB) is a table
maintained by the CPU which holds recently
used main-to-virtual 'translations’
( diigo.com/085lsy )
+ Linux Kernel
CODE
DATA
STACK
CACHE
TLBVirtual MemoryVirtual Memory
P
PP P
P
H H
Kernel
+ Memory Management
Linux Kernel Memory Management
Managing virtual memory is the 'heaviest' task of
the Linux Kernel
It makes most of the OS advanced features
possible
Either dig deep, or run auto-pilot
( Tuned and Ktune diigo.com/085ltv )
+ Memory Management
Linux Kernel Memory Management
Linux Kernel uses VM to provide a much larger
memory than the amount of physical memory
When a memory page needs to be written and
there isnt a free page on physical memory Linux
uses swapping to ‘make room’ for that page
Linux Kernel uses LRU (Least Recently Used)
algorithm to calculate which page is to be
‘swapped out’
+ Memory Management
Random Access Memory
RAM is being used by the Kernel for
– Storing the Kernel Code and Data
– Handle Kernel's buffers and descriptors
requests
– Handle Processes generic memory areas
and file mapping requests
– *Cache buffered devices I/O
+ Memory Management
Random Access Memory
Dividing the limited amount of RAM between all
of these tasks is crucial if one is to achieve
proper performance from the system
Memory fragmentation can also be a set back in
terms of performance and needs to be dealt with
by the Kernel
+ Memory Management
Kernel Memory Allocator
KMA is a kernel subsystem which handles
memory allocation requests from all portions of
the OS
Linux Kernel uses SLAB allocator with the
'buddy' algorithm
– Allocate pages according to request type
– Reuses kernel functions (e.g: exec)
metadata pages
+ Memory Management
Process Virtual Address Space
The address space of each process contains all
of the memory addresses which are accessible
to that process, including:
 execute code
 un/initialized program data
 shared libraries
 heap
+ Memory Management
Process Virtual Address Space
The Linux Kernel uses advanced strategies in
order to improve performance on these tasks
– Demand Paging: Allows a program to
start execution before all of it's pages are
actually loaded
– Copy-on-Write: Fork child processes with
a read-only reference to the parent
process address space
+ Memory Management
Cache (Page Cache)
Most of the available RAM on the system is used
as a buffered I/O cache.
This is done in order to improve performance
when working with 'slow' devices
Write cache ('dirty' buffers) is being periodically
'sync'ed to the original device
+ Memory Management
Cache (Page Cache)
Linux Kernel caches pages which contains
 Data being processed from a file system
 Data being processed directly from a block device
 Both files and directories data
 File structure, inodes, etc’
 User mode process data which was swapped out
+ Memory Management
Cache (Page Cache)
To disable the page cache for a certain
operation, the relevant system call, should be
called with the flag O_DIRECT
Use the command ‘readahead’ to load a file list
into the Page Cache for later processing
+ Memory Management
Huge Pages
Linux uses 'page' as the smallest portion of RAM
being mapped
When mapping a huge size of sequential pages,
there is a noticeable overhead for managing
these pages
Huge pages address this problem by eliminating
the limitation of small (default: 4k) page size
+ Memory Management
Kernel Threads
Some of the Kernel tasks related to VM
management are being done using kernel
threads
 Keventd (aka events)
 Kswapd
 Pdflush
 Kblockd
 Kjournald
+ Memory Management
Kernel Tune able Parameters
Most of the mechanisms described throughout
this course can be tuned using the 'sysctl' or
'/proc' interfaces
In order to keep track of the tune able
parameters default values, inner-relations and
current effect, make sure to consult the kernel
Documentation tree
(/usr/share/doc/kernel-*/Documentation)
+ Memory Management
Kernel Tune able Parameters
 'drop_caches': invokes a cache 'sync' and
free up cached memory
 'vfs_cache_pressure': tune the amount of
resources put into reclaiming inodes and
dentries cache
'dirty_background_ratio': when will pdflush start writing out 'dirty' data
+ Memory Management
Kernel Tune able Parameters
 'dirty_writeback_centisecs': pdflush
interval
 'dirty_expire_centisecs': page's maximum
'age' before pdflush writes it out to disk
+ Memory Management
Kernel Tune able Parameters
 'page-cluster': number of pages written to
SWAP during swap in (logarithmic)
 'nr_hugepages': number of allocated huge
pages (works with 'hugetlb_shm_group')
+ Memory Management
Linux Kernel Memory Management
Use the following commands to review memory
information
 'top'
 'vmstat’
 ‘sar’
 'free’
 ‘cat /proc/meminfo’
+ Memory Management
Linux Kernel Memory Management
Exercise
Try Using the following script to overview page
cache usage #!/bin/bash
trap 'pkill "$*"' INT# **
]] -z $1 ]] && exit 2
B=$(free | awk '/^Mem/ {print $7{'(
echo Before: $B >&2
$*
A=$(free | awk '/^Mem/ {print $7{'(
echo Before: $B After: $A >&2
echo "--------------" >&2
echo Total: $(( $A - $B )) >&2

More Related Content

What's hot

RocksDB Performance and Reliability Practices
RocksDB Performance and Reliability PracticesRocksDB Performance and Reliability Practices
RocksDB Performance and Reliability Practices
Yoshinori Matsunobu
 
Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...
Adrian Huang
 
Linux MMAP & Ioremap introduction
Linux MMAP & Ioremap introductionLinux MMAP & Ioremap introduction
Linux MMAP & Ioremap introduction
Gene Chang
 
Linux Kernel - Virtual File System
Linux Kernel - Virtual File SystemLinux Kernel - Virtual File System
Linux Kernel - Virtual File System
Adrian Huang
 
Kvm performance optimization for ubuntu
Kvm performance optimization for ubuntuKvm performance optimization for ubuntu
Kvm performance optimization for ubuntu
Sim Janghoon
 
TPC-H Column Store and MPP systems
TPC-H Column Store and MPP systemsTPC-H Column Store and MPP systems
TPC-H Column Store and MPP systems
Mostafa Mokhtar
 
Ext4 filesystem(1)
Ext4 filesystem(1)Ext4 filesystem(1)
Ext4 filesystem(1)
Yoshihiro Yunomae
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
Suvendu Kumar Dash
 
LISA2019 Linux Systems Performance
LISA2019 Linux Systems PerformanceLISA2019 Linux Systems Performance
LISA2019 Linux Systems Performance
Brendan Gregg
 
Linux kernel memory allocators
Linux kernel memory allocatorsLinux kernel memory allocators
Linux kernel memory allocators
Hao-Ran Liu
 
Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...
Adrian Huang
 
Linux memory
Linux memoryLinux memory
Linux memory
ericrain911
 
Memory management in Linux
Memory management in LinuxMemory management in Linux
Memory management in Linux
Raghu Udiyar
 
Physical Memory Models.pdf
Physical Memory Models.pdfPhysical Memory Models.pdf
Physical Memory Models.pdf
Adrian Huang
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and Monitoring
Georg Schönberger
 
Slab Allocator in Linux Kernel
Slab Allocator in Linux KernelSlab Allocator in Linux Kernel
Slab Allocator in Linux Kernel
Adrian Huang
 
Linux Memory
Linux MemoryLinux Memory
Linux Memory
Vitaly Nahshunov
 
Demystifying flink memory allocation and tuning - Roshan Naik, Uber
Demystifying flink memory allocation and tuning - Roshan Naik, UberDemystifying flink memory allocation and tuning - Roshan Naik, Uber
Demystifying flink memory allocation and tuning - Roshan Naik, Uber
Flink Forward
 
Transparent Hugepages in RHEL 6
Transparent Hugepages in RHEL 6 Transparent Hugepages in RHEL 6
Transparent Hugepages in RHEL 6
Raghu Udiyar
 
Facebook Messages & HBase
Facebook Messages & HBaseFacebook Messages & HBase
Facebook Messages & HBase
强 王
 

What's hot (20)

RocksDB Performance and Reliability Practices
RocksDB Performance and Reliability PracticesRocksDB Performance and Reliability Practices
RocksDB Performance and Reliability Practices
 
Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...
 
Linux MMAP & Ioremap introduction
Linux MMAP & Ioremap introductionLinux MMAP & Ioremap introduction
Linux MMAP & Ioremap introduction
 
Linux Kernel - Virtual File System
Linux Kernel - Virtual File SystemLinux Kernel - Virtual File System
Linux Kernel - Virtual File System
 
Kvm performance optimization for ubuntu
Kvm performance optimization for ubuntuKvm performance optimization for ubuntu
Kvm performance optimization for ubuntu
 
TPC-H Column Store and MPP systems
TPC-H Column Store and MPP systemsTPC-H Column Store and MPP systems
TPC-H Column Store and MPP systems
 
Ext4 filesystem(1)
Ext4 filesystem(1)Ext4 filesystem(1)
Ext4 filesystem(1)
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
LISA2019 Linux Systems Performance
LISA2019 Linux Systems PerformanceLISA2019 Linux Systems Performance
LISA2019 Linux Systems Performance
 
Linux kernel memory allocators
Linux kernel memory allocatorsLinux kernel memory allocators
Linux kernel memory allocators
 
Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...
 
Linux memory
Linux memoryLinux memory
Linux memory
 
Memory management in Linux
Memory management in LinuxMemory management in Linux
Memory management in Linux
 
Physical Memory Models.pdf
Physical Memory Models.pdfPhysical Memory Models.pdf
Physical Memory Models.pdf
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and Monitoring
 
Slab Allocator in Linux Kernel
Slab Allocator in Linux KernelSlab Allocator in Linux Kernel
Slab Allocator in Linux Kernel
 
Linux Memory
Linux MemoryLinux Memory
Linux Memory
 
Demystifying flink memory allocation and tuning - Roshan Naik, Uber
Demystifying flink memory allocation and tuning - Roshan Naik, UberDemystifying flink memory allocation and tuning - Roshan Naik, Uber
Demystifying flink memory allocation and tuning - Roshan Naik, Uber
 
Transparent Hugepages in RHEL 6
Transparent Hugepages in RHEL 6 Transparent Hugepages in RHEL 6
Transparent Hugepages in RHEL 6
 
Facebook Messages & HBase
Facebook Messages & HBaseFacebook Messages & HBase
Facebook Messages & HBase
 

Viewers also liked

Linux Performance Tunning introduction
Linux Performance Tunning introductionLinux Performance Tunning introduction
Linux Performance Tunning introduction
Shay Cohen
 
Infra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automationInfra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automation
Shay Cohen
 
Linux Performance Tunning Kernel
Linux Performance Tunning KernelLinux Performance Tunning Kernel
Linux Performance Tunning Kernel
Shay Cohen
 
chroot and SELinux
chroot and SELinuxchroot and SELinux
chroot and SELinux
Shay Cohen
 
01 linux history overview
01 linux history overview01 linux history overview
01 linux history overview
Shay Cohen
 
09 string processing_with_regex copy
09 string processing_with_regex copy09 string processing_with_regex copy
09 string processing_with_regex copy
Shay Cohen
 
06 users groups_and_permissions
06 users groups_and_permissions06 users groups_and_permissions
06 users groups_and_permissions
Shay Cohen
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editor
Shay Cohen
 
05 standard io_and_pipes
05 standard io_and_pipes05 standard io_and_pipes
05 standard io_and_pipes
Shay Cohen
 
10 finding files
10 finding files10 finding files
10 finding files
Shay Cohen
 
12 linux archiving tools
12 linux archiving tools12 linux archiving tools
12 linux archiving tools
Shay Cohen
 
03 browsing the filesystem
03 browsing the filesystem03 browsing the filesystem
03 browsing the filesystem
Shay Cohen
 
02 linux desktop usage
02 linux desktop usage02 linux desktop usage
02 linux desktop usage
Shay Cohen
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/Core
Shay Cohen
 
04 using and_configuring_bash
04 using and_configuring_bash04 using and_configuring_bash
04 using and_configuring_bash
Shay Cohen
 
13 process management
13 process management13 process management
13 process management
Shay Cohen
 
11 linux filesystem copy
11 linux filesystem copy11 linux filesystem copy
11 linux filesystem copy
Shay Cohen
 
14 network tools
14 network tools14 network tools
14 network tools
Shay Cohen
 
08 text processing_tools
08 text processing_tools08 text processing_tools
08 text processing_tools
Shay Cohen
 
Introduction to SELinux Part-I
Introduction to SELinux Part-IIntroduction to SELinux Part-I
Introduction to SELinux Part-I
n|u - The Open Security Community
 

Viewers also liked (20)

Linux Performance Tunning introduction
Linux Performance Tunning introductionLinux Performance Tunning introduction
Linux Performance Tunning introduction
 
Infra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automationInfra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automation
 
Linux Performance Tunning Kernel
Linux Performance Tunning KernelLinux Performance Tunning Kernel
Linux Performance Tunning Kernel
 
chroot and SELinux
chroot and SELinuxchroot and SELinux
chroot and SELinux
 
01 linux history overview
01 linux history overview01 linux history overview
01 linux history overview
 
09 string processing_with_regex copy
09 string processing_with_regex copy09 string processing_with_regex copy
09 string processing_with_regex copy
 
06 users groups_and_permissions
06 users groups_and_permissions06 users groups_and_permissions
06 users groups_and_permissions
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editor
 
05 standard io_and_pipes
05 standard io_and_pipes05 standard io_and_pipes
05 standard io_and_pipes
 
10 finding files
10 finding files10 finding files
10 finding files
 
12 linux archiving tools
12 linux archiving tools12 linux archiving tools
12 linux archiving tools
 
03 browsing the filesystem
03 browsing the filesystem03 browsing the filesystem
03 browsing the filesystem
 
02 linux desktop usage
02 linux desktop usage02 linux desktop usage
02 linux desktop usage
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/Core
 
04 using and_configuring_bash
04 using and_configuring_bash04 using and_configuring_bash
04 using and_configuring_bash
 
13 process management
13 process management13 process management
13 process management
 
11 linux filesystem copy
11 linux filesystem copy11 linux filesystem copy
11 linux filesystem copy
 
14 network tools
14 network tools14 network tools
14 network tools
 
08 text processing_tools
08 text processing_tools08 text processing_tools
08 text processing_tools
 
Introduction to SELinux Part-I
Introduction to SELinux Part-IIntroduction to SELinux Part-I
Introduction to SELinux Part-I
 

Similar to Linux Performance Tunning Memory

Nachos 2
Nachos 2Nachos 2
Nachos 2
Eduardo Triana
 
Visual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & VirtualisationVisual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & Virtualisation
wangyuanyi
 
I/O System and Case study
I/O System and Case studyI/O System and Case study
I/O System and Case study
malarselvi mms
 
Os
OsOs
Linux introduction
Linux introductionLinux introduction
Linux introduction
Abhishek Khune
 
I/O System and Case Study
I/O System and Case StudyI/O System and Case Study
I/O System and Case Study
GRamya Bharathi
 
Refining Linux
Refining LinuxRefining Linux
Refining Linux
Jason Murray
 
Operating system ppt
Operating system pptOperating system ppt
Operating system ppt
kaviya kumaresan
 
Operating system ppt
Operating system pptOperating system ppt
Operating system ppt
kaviya kumaresan
 
Operating system ppt
Operating system pptOperating system ppt
Operating system ppt
kaviya kumaresan
 
Operating system ppt
Operating system pptOperating system ppt
Operating system ppt
kaviya kumaresan
 
Io sy.stemppt
Io sy.stempptIo sy.stemppt
Io sy.stemppt
muthumani mahesh
 
virtual memory - Computer operating system
virtual memory - Computer operating systemvirtual memory - Computer operating system
virtual memory - Computer operating system
Electronics - Embedded System
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdf
Kadu37
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdf
ssuser143a20
 
Operation System
Operation SystemOperation System
Operation System
ANANTHI1997
 
Operation System
Operation SystemOperation System
Operation System
ROHINIPRIYA1997
 
Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)
Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)
Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)
Suresh Kumar
 
Vmwareperformancetroubleshooting 100224104321-phpapp02
Vmwareperformancetroubleshooting 100224104321-phpapp02Vmwareperformancetroubleshooting 100224104321-phpapp02
Vmwareperformancetroubleshooting 100224104321-phpapp02
Suresh Kumar
 
Walking around linux kernel
Walking around linux kernelWalking around linux kernel
Walking around linux kernel
Dharshana Kasun Warusavitharana
 

Similar to Linux Performance Tunning Memory (20)

Nachos 2
Nachos 2Nachos 2
Nachos 2
 
Visual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & VirtualisationVisual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & Virtualisation
 
I/O System and Case study
I/O System and Case studyI/O System and Case study
I/O System and Case study
 
Os
OsOs
Os
 
Linux introduction
Linux introductionLinux introduction
Linux introduction
 
I/O System and Case Study
I/O System and Case StudyI/O System and Case Study
I/O System and Case Study
 
Refining Linux
Refining LinuxRefining Linux
Refining Linux
 
Operating system ppt
Operating system pptOperating system ppt
Operating system ppt
 
Operating system ppt
Operating system pptOperating system ppt
Operating system ppt
 
Operating system ppt
Operating system pptOperating system ppt
Operating system ppt
 
Operating system ppt
Operating system pptOperating system ppt
Operating system ppt
 
Io sy.stemppt
Io sy.stempptIo sy.stemppt
Io sy.stemppt
 
virtual memory - Computer operating system
virtual memory - Computer operating systemvirtual memory - Computer operating system
virtual memory - Computer operating system
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdf
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdf
 
Operation System
Operation SystemOperation System
Operation System
 
Operation System
Operation SystemOperation System
Operation System
 
Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)
Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)
Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)
 
Vmwareperformancetroubleshooting 100224104321-phpapp02
Vmwareperformancetroubleshooting 100224104321-phpapp02Vmwareperformancetroubleshooting 100224104321-phpapp02
Vmwareperformancetroubleshooting 100224104321-phpapp02
 
Walking around linux kernel
Walking around linux kernelWalking around linux kernel
Walking around linux kernel
 

Recently uploaded

GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
Sease
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
LizaNolte
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
Fwdays
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
UiPathCommunity
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
Vadym Kazulkin
 

Recently uploaded (20)

GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
 

Linux Performance Tunning Memory

  • 2. + Memory Management Linux Kernel Memory Management ( https://www.kernel.org/doc/Documentation/vm/ ) Linux uses Virtual Memory to manage the address space of the entire OS VM extends the size of the physical memory All OS processes 'live' in the VM and can occasionally be relocated due to the kernel demand
  • 3. + Memory Management Linux Kernel Memory Management Memory Manager Unit (MMU) is an implementation of a hardware object ( in the CPU ) which manages the VM Translation Lookaside Buffer (TLB) is a table maintained by the CPU which holds recently used main-to-virtual 'translations’ ( diigo.com/085lsy )
  • 4. + Linux Kernel CODE DATA STACK CACHE TLBVirtual MemoryVirtual Memory P PP P P H H Kernel
  • 5. + Memory Management Linux Kernel Memory Management Managing virtual memory is the 'heaviest' task of the Linux Kernel It makes most of the OS advanced features possible Either dig deep, or run auto-pilot ( Tuned and Ktune diigo.com/085ltv )
  • 6. + Memory Management Linux Kernel Memory Management Linux Kernel uses VM to provide a much larger memory than the amount of physical memory When a memory page needs to be written and there isnt a free page on physical memory Linux uses swapping to ‘make room’ for that page Linux Kernel uses LRU (Least Recently Used) algorithm to calculate which page is to be ‘swapped out’
  • 7. + Memory Management Random Access Memory RAM is being used by the Kernel for – Storing the Kernel Code and Data – Handle Kernel's buffers and descriptors requests – Handle Processes generic memory areas and file mapping requests – *Cache buffered devices I/O
  • 8. + Memory Management Random Access Memory Dividing the limited amount of RAM between all of these tasks is crucial if one is to achieve proper performance from the system Memory fragmentation can also be a set back in terms of performance and needs to be dealt with by the Kernel
  • 9. + Memory Management Kernel Memory Allocator KMA is a kernel subsystem which handles memory allocation requests from all portions of the OS Linux Kernel uses SLAB allocator with the 'buddy' algorithm – Allocate pages according to request type – Reuses kernel functions (e.g: exec) metadata pages
  • 10. + Memory Management Process Virtual Address Space The address space of each process contains all of the memory addresses which are accessible to that process, including:  execute code  un/initialized program data  shared libraries  heap
  • 11. + Memory Management Process Virtual Address Space The Linux Kernel uses advanced strategies in order to improve performance on these tasks – Demand Paging: Allows a program to start execution before all of it's pages are actually loaded – Copy-on-Write: Fork child processes with a read-only reference to the parent process address space
  • 12. + Memory Management Cache (Page Cache) Most of the available RAM on the system is used as a buffered I/O cache. This is done in order to improve performance when working with 'slow' devices Write cache ('dirty' buffers) is being periodically 'sync'ed to the original device
  • 13. + Memory Management Cache (Page Cache) Linux Kernel caches pages which contains  Data being processed from a file system  Data being processed directly from a block device  Both files and directories data  File structure, inodes, etc’  User mode process data which was swapped out
  • 14. + Memory Management Cache (Page Cache) To disable the page cache for a certain operation, the relevant system call, should be called with the flag O_DIRECT Use the command ‘readahead’ to load a file list into the Page Cache for later processing
  • 15. + Memory Management Huge Pages Linux uses 'page' as the smallest portion of RAM being mapped When mapping a huge size of sequential pages, there is a noticeable overhead for managing these pages Huge pages address this problem by eliminating the limitation of small (default: 4k) page size
  • 16. + Memory Management Kernel Threads Some of the Kernel tasks related to VM management are being done using kernel threads  Keventd (aka events)  Kswapd  Pdflush  Kblockd  Kjournald
  • 17. + Memory Management Kernel Tune able Parameters Most of the mechanisms described throughout this course can be tuned using the 'sysctl' or '/proc' interfaces In order to keep track of the tune able parameters default values, inner-relations and current effect, make sure to consult the kernel Documentation tree (/usr/share/doc/kernel-*/Documentation)
  • 18. + Memory Management Kernel Tune able Parameters  'drop_caches': invokes a cache 'sync' and free up cached memory  'vfs_cache_pressure': tune the amount of resources put into reclaiming inodes and dentries cache 'dirty_background_ratio': when will pdflush start writing out 'dirty' data
  • 19. + Memory Management Kernel Tune able Parameters  'dirty_writeback_centisecs': pdflush interval  'dirty_expire_centisecs': page's maximum 'age' before pdflush writes it out to disk
  • 20. + Memory Management Kernel Tune able Parameters  'page-cluster': number of pages written to SWAP during swap in (logarithmic)  'nr_hugepages': number of allocated huge pages (works with 'hugetlb_shm_group')
  • 21. + Memory Management Linux Kernel Memory Management Use the following commands to review memory information  'top'  'vmstat’  ‘sar’  'free’  ‘cat /proc/meminfo’
  • 22. + Memory Management Linux Kernel Memory Management Exercise Try Using the following script to overview page cache usage #!/bin/bash trap 'pkill "$*"' INT# ** ]] -z $1 ]] && exit 2 B=$(free | awk '/^Mem/ {print $7{'( echo Before: $B >&2 $* A=$(free | awk '/^Mem/ {print $7{'( echo Before: $B After: $A >&2 echo "--------------" >&2 echo Total: $(( $A - $B )) >&2

Editor's Notes

  1. COW - Where do we know this from ? *Kernel RAM management issues, are partially like well-known common storage management issues