SlideShare a Scribd company logo
1 of 22
Download to read offline
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

LCA14: LCA14-306: CPUidle & CPUfreq integration with scheduler
LCA14: LCA14-306: CPUidle & CPUfreq integration with schedulerLCA14: LCA14-306: CPUidle & CPUfreq integration with scheduler
LCA14: LCA14-306: CPUidle & CPUfreq integration with schedulerLinaro
 
Linux Kernel - Virtual File System
Linux Kernel - Virtual File SystemLinux Kernel - Virtual File System
Linux Kernel - Virtual File SystemAdrian Huang
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device driversHoucheng Lin
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringGeorg Schönberger
 
Testing real-time Linux. What to test and how
Testing real-time Linux. What to test and how Testing real-time Linux. What to test and how
Testing real-time Linux. What to test and how Chirag Jog
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory ManagementNi Zo-Ma
 
malloc & vmalloc in Linux
malloc & vmalloc in Linuxmalloc & vmalloc in Linux
malloc & vmalloc in LinuxAdrian Huang
 
Static partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VStatic partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VRISC-V International
 
Physical Memory Models.pdf
Physical Memory Models.pdfPhysical Memory Models.pdf
Physical Memory Models.pdfAdrian Huang
 
Linux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBLinux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBshimosawa
 
Memory management in Linux
Memory management in LinuxMemory management in Linux
Memory management in LinuxRaghu Udiyar
 
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...The Linux Foundation
 
Yocto project and open embedded training
Yocto project and open embedded trainingYocto project and open embedded training
Yocto project and open embedded trainingH Ming
 
OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?ScyllaDB
 
Linux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old SecretsLinux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old SecretsBrendan Gregg
 
Troubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device DriversTroubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device DriversSatpal Parmar
 

What's hot (20)

LCA14: LCA14-306: CPUidle & CPUfreq integration with scheduler
LCA14: LCA14-306: CPUidle & CPUfreq integration with schedulerLCA14: LCA14-306: CPUidle & CPUfreq integration with scheduler
LCA14: LCA14-306: CPUidle & CPUfreq integration with scheduler
 
Linux Kernel - Virtual File System
Linux Kernel - Virtual File SystemLinux Kernel - Virtual File System
Linux Kernel - Virtual File System
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and Monitoring
 
Vfs
VfsVfs
Vfs
 
Linux Internals - Part I
Linux Internals - Part ILinux Internals - Part I
Linux Internals - Part I
 
Testing real-time Linux. What to test and how
Testing real-time Linux. What to test and how Testing real-time Linux. What to test and how
Testing real-time Linux. What to test and how
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
malloc & vmalloc in Linux
malloc & vmalloc in Linuxmalloc & vmalloc in Linux
malloc & vmalloc in Linux
 
Static partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VStatic partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-V
 
Physical Memory Models.pdf
Physical Memory Models.pdfPhysical Memory Models.pdf
Physical Memory Models.pdf
 
Linux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBLinux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKB
 
Memory management in Linux
Memory management in LinuxMemory management in Linux
Memory management in Linux
 
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
 
Yocto project and open embedded training
Yocto project and open embedded trainingYocto project and open embedded training
Yocto project and open embedded training
 
Linux-Internals-and-Networking
Linux-Internals-and-NetworkingLinux-Internals-and-Networking
Linux-Internals-and-Networking
 
OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?
 
Linux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old SecretsLinux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old Secrets
 
Troubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device DriversTroubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device Drivers
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 

Viewers also liked

Linux Performance Tunning introduction
Linux Performance Tunning introductionLinux Performance Tunning introduction
Linux Performance Tunning introductionShay Cohen
 
Infra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automationInfra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automationShay Cohen
 
Linux Performance Tunning Kernel
Linux Performance Tunning KernelLinux Performance Tunning Kernel
Linux Performance Tunning KernelShay Cohen
 
chroot and SELinux
chroot and SELinuxchroot and SELinux
chroot and SELinuxShay Cohen
 
01 linux history overview
01 linux history overview01 linux history overview
01 linux history overviewShay Cohen
 
09 string processing_with_regex copy
09 string processing_with_regex copy09 string processing_with_regex copy
09 string processing_with_regex copyShay Cohen
 
06 users groups_and_permissions
06 users groups_and_permissions06 users groups_and_permissions
06 users groups_and_permissionsShay Cohen
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editorShay Cohen
 
05 standard io_and_pipes
05 standard io_and_pipes05 standard io_and_pipes
05 standard io_and_pipesShay Cohen
 
10 finding files
10 finding files10 finding files
10 finding filesShay Cohen
 
12 linux archiving tools
12 linux archiving tools12 linux archiving tools
12 linux archiving toolsShay Cohen
 
03 browsing the filesystem
03 browsing the filesystem03 browsing the filesystem
03 browsing the filesystemShay Cohen
 
02 linux desktop usage
02 linux desktop usage02 linux desktop usage
02 linux desktop usageShay Cohen
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/CoreShay Cohen
 
04 using and_configuring_bash
04 using and_configuring_bash04 using and_configuring_bash
04 using and_configuring_bashShay Cohen
 
13 process management
13 process management13 process management
13 process managementShay Cohen
 
11 linux filesystem copy
11 linux filesystem copy11 linux filesystem copy
11 linux filesystem copyShay Cohen
 
14 network tools
14 network tools14 network tools
14 network toolsShay Cohen
 
08 text processing_tools
08 text processing_tools08 text processing_tools
08 text processing_toolsShay Cohen
 

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

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 & Virtualisationwangyuanyi
 
I/O System and Case study
I/O System and Case studyI/O System and Case study
I/O System and Case studymalarselvi mms
 
I/O System and Case Study
I/O System and Case StudyI/O System and Case Study
I/O System and Case StudyGRamya Bharathi
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdfKadu37
 
Operation System
Operation SystemOperation System
Operation SystemANANTHI1997
 
Vmwareperformancetroubleshooting 100224104321-phpapp02
Vmwareperformancetroubleshooting 100224104321-phpapp02Vmwareperformancetroubleshooting 100224104321-phpapp02
Vmwareperformancetroubleshooting 100224104321-phpapp02Suresh Kumar
 
Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)
Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)
Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)Suresh Kumar
 

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
Vmwareperformancetroubleshooting 100224104321-phpapp02Vmwareperformancetroubleshooting 100224104321-phpapp02
Vmwareperformancetroubleshooting 100224104321-phpapp02
 
Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)
Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)
Vmwareperformancetroubleshooting 100224104321-phpapp02 (1)
 
Walking around linux kernel
Walking around linux kernelWalking around linux kernel
Walking around linux kernel
 

Recently uploaded

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 

Recently uploaded (20)

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 

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