《system performance》&《BPF PerformanceTools》读书笔记(四)Memory

背景及概念

书里对内存的背景知识介绍得比较全面,包含了Linux内存管理的大部分概念。内存这个资源有些特殊,相比其他如CPU,磁盘,网络等资源,并不是用的越满性能就越差,内存是一块访问速度较快的存储资源,放在那里不用就是白白浪费。Linux的内存管理对申请内存比较开放,除非设置了限制通常不会过度干预,很多策略放了在回收过程中,当不够用的时候再去考虑从哪里回收内存。对于性能分析来讲需要重点关注回收流程,回收内存对系统性能有何影响,保留哪些内存收益更大,是应该重点关注的问题。

1.虚拟内存及映射

虚拟内存是一个抽象概念,它为每个进程及内核提供了一个几乎无限大的线性的私有地址空间,这使得程序开发变得十分便利,不用考虑内存冲突的问题,由内存管理子系统负责所有虚拟地址到物理地址的映射,物理地址可以是实际的物理内存(Primary memory),也可以是交换分区(swap)。

2.Paging

内存页移入或移出Primary memory的过程,可分为page-in和page-out。按内存类别又可分为:

File System Paging

读写memory-mapped的文件时产生,通常是应用调用mmap(),或者读写文件时用到pagecache。

Anonymous Paging

进程的匿名页被换入或者换出swap设备产生,Linux也用swapping来代表这类paging。

3.内存分配器

内核以页为单位管理内存,提供了申请/释放内存页的接口,但仍有很多问题没有解决。比如申请小于一页的小块内存造成的浪费,频繁申请释放带来的性能损耗与内存碎片。各种内存分配器被设计出来解决这些问题,有内核里的slab,slub,应用层常用的libc , tmalloc 等等,这些分配器的行为会对性能造成很大影响

BPF and related observability tools give software professionals unprecedented visibility into software, helping them analyze operating system and application performance, troubleshoot code, and strengthen security. BPF Performance Tools: Linux System and Application Observability is the industry’s most comprehensive guide to using these tools for observability. Brendan Gregg, author of the industry’s definitive guide to system performance, introduces powerful new methods and tools for doing analysis that leads to more robust, reliable, and safer code. This authoritative guide: Explores a wide spectrum of software and hardware targets Thoroughly covers open source BPF tools from the Linux Foundation iovisor project’s bcc and bpftrace repositories Summarizes performance engineering and kernel internals you need to understand Provides and discusses 150+ bpftrace tools, including 80 written specifically for this book: tools you can run as-is, without programming — or customize and develop further, using diverse interfaces and the bpftrace front-end You’ll learn how to use BPF (eBPF) tracing tools to analyze CPUs, memory, disks, file systems, networking, languages, applications, containers, hypervisors, security, and the Linux kernel. You’ll move from basic to advanced tools and techniques, producing new metrics, stack traces, custom latency histograms, and more. It’s like having a superpower: with Gregg’s guidance and tools, you can analyze virtually everything that impacts system performance, so you can improve virtually any Linux operating system or application.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值