物理核与逻辑核-转 perf
Linux和Windows 物理CPU、物理核、逻辑核——区别、关系和查看
cat /proc/cpuinfo命令部分输出信息的含义
physical id 物理封装的处理器的id
processor 逻辑核的id
core id 一颗处理器中的每个物理核的id
cpu cores 位于相同物理封装的处理器中的物理核的数量
siblings 位于相同物理封装的处理器中的逻辑核的数量
这个现场和intel的fae交流了一下,同一个物理核上的2个逻辑核(core 0, core 28),共享L1,L12cache,指令发射、执行电路。当同一个硬核上的2个逻辑核,只有一个在使用的时候,他的cache 命中率,IPC(instructions per cycle)都会提高,执行相同的工作任务,由于执行效率提高,cpu 利用率就会下降(当然,具体还和cpu利用率计算的方式也有关系)。
下面是perf的数据, core 0和core28属于同一个物理核,core6和core34属于同一个物理核,可以看到core28的ipc明显高于core6和core34的。用perf观察cache-miss的数据,也有类似结论,不在邮件里面列出了。
perf stat -C 28
946726278451 instructions # 1.19 insns per cycle (100.00%)
perf stat -C 6
101232784938 instructions # 1.00 insns per cycle (100.00%)
perf stat -C 34
43894836578 instructions # 0.87 insns per cycle (100.00%)
概念区分和查看方法
1. CPU(处理器)数量:主板插槽上(物理封装上)的CPU芯片的个数
在cat /proc/cpuinfo 命令的输出中,每颗物理CPU都有唯一id号(即 physical id,从0开始标号),CPU数量即不同 physical id 的数量。
所以,查看CPU数量的命令:
# cat /proc/cpuinfo | grep "physical id" // 查看所有的physical id,有多少个不同physical id就有多少颗CPU
# cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l // 查看不同physical id的数量,直接输出CPU数量
2. CPU物理核数(Core):一颗物理CPU中包含的内核数量(Core)
在cat /proc/cpuinfo 命令的输出中,每颗CPU里的每个物理核(核心,内核)都有id号(即 core id,从0开始标号)。相同物理封装的CPU的物理核数即不同 core id 的数量。cpu cores的值也直接表示CPU物理核数。
所以,查看CPU物理核数的命令:
# cat /proc/cpuinfo | grep "cpu cores" // 查看cpu cores的值,即CPU物理核数
# cat /proc/cpuinfo | grep "core id" | sort -u | wc -l // 查看不同core id的数量,直接输出CPU物理核数(注意:输出的是一颗CPU的物理核数)
3. CPU逻辑核数(CPU线程数,Thread):通过超线程技术,能将一个物理核分成多个逻辑核
一般情况,一颗物理CPU可以有多个物理内核,加上intel的超线程技术(HT, Hyper-Threading)能够把一个物理处理器(核心,内核)在软件层变成两个逻辑处理器,可以使处理器在某一时刻,同步并行处理更多指令和数据(即有多个线程并行工作)。
在cat /proc/cpuinfo 命令的输出中,processor的值表示逻辑处理器(逻辑核)的id号,CPU逻辑核数即不同 processor 的数量。
所以,查看CPU逻辑核数的命令:
# cat /proc/cpuinfo | grep "processor" | sort -u | wc -l // 查看不同 processor 的数量,直接输出CPU逻辑核数总数(注意:输出的是本服务器所有CPU的逻辑核的总数)
查看CPU是否支持超线程
命令:cat /proc/cpuinfo
若:
siblings = cpu cores 不支持超线程 或 未启用超线程
siblings > cpu cores 支持并已启用超线程
“siblings”指的是一颗物理CPU有几个逻辑核,“cpu cores”指的是一颗物理CPU有几个物理核。
计算服务器的物理核、逻辑核的总数
服务器的CPU物理核总数 = CPU数量 × 每颗CPU的物理核数(cpu cores)
服务器的CPU逻辑核总数 = CPU数量 × 每颗CPU的逻辑核数(siblings)
Linux和Windows查看CPU信息
- linux系统: cat /proc/cpuinfo 或 lscpu
- Windows系统:ctrl + alt + delete 打开“任务管理器”-->“性能”
============================== 分割线 ==================================
实际操作——分别在 CentOS 和 Windows10 查看CPU信息
1、CentOS(1 CPU四核四线程):
[root@localhost ~]# cat /proc/cpuinfo
processor : 0 # 逻辑核 id号
vendor_id : GenuineIntel
cpu family : 6
model : 61
model name : Intel Core Processor (Broadwell)
stepping : 2
microcode : 0x1
cpu MHz : 2095.146
cache size : 16384 KB
physical id : 0 # 物理CPU id号
siblings : 4 # 该逻辑核所在的物理CPU的逻辑核数
core id : 0 # 物理核 id号
cpu cores : 4 # 该逻辑核所在的物理CPU的物理核数
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap xsaveopt arat
bogomips : 4190.29
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 61
model name : Intel Core Processor (Broadwell)
stepping : 2
microcode : 0x1
cpu MHz : 2095.146
cache size : 16384 KB
physical id : 0
siblings : 4
core id : 1
cpu cores : 4
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap xsaveopt arat
bogomips : 4190.29
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 2
vendor_id : GenuineIntel
cpu family : 6
model : 61
model name : Intel Core Processor (Broadwell)
stepping : 2
microcode : 0x1
cpu MHz : 2095.146
cache size : 16384 KB
physical id : 0
siblings : 4
core id : 2
cpu cores : 4
apicid : 2
initial apicid : 2
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap xsaveopt arat
bogomips : 4190.29
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 3
vendor_id : GenuineIntel
cpu family : 6
model : 61
model name : Intel Core Processor (Broadwell)
stepping : 2
microcode : 0x1
cpu MHz : 2095.146
cache size : 16384 KB
physical id : 0
siblings : 4
core id : 3
cpu cores : 4
apicid : 3
initial apicid : 3
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap xsaveopt arat
bogomips : 4190.29
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
[root@localhost ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1 # 每个物理核的线程数(逻辑核数)
Core(s) per socket: 4 # 每个颗物理CPU的物理核数
Socket(s): 1 # 物理CPU插槽数
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 61
Model name: Intel Core Processor (Broadwell)
Stepping: 2
CPU MHz: 2095.146
BogoMIPS: 4190.29
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 4096K
L3 cache: 16384K
NUMA node0 CPU(s): 0-3
Flags: fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap xsaveopt arat
2、 Windows10(1 CPU两核四线程):
ctrl + alt + delete 打开“任务管理器”,点击“性能”

完~
2019.12.06更新
物理核与逻辑核-转 perf的更多相关文章
- 物理CPU、物理核跟逻辑核的区分
一般来说,物理CPU个数×每颗核数就应该等于逻辑CPU的个数,如果不相等的话,则表示服务器的CPU支持超线程技术 ,所以您的电脑是双核的. 一 概念① 物理CPU 实际Server中插槽上的CPU个数 ...
- powershell 获取 CPU 物理 / 逻辑核心数
转载请注明: 仰望高端玩家的小清新 http://www.cnblogs.com/luruiyuan/ 获取 CPU 逻辑核心数的方法为:总逻辑核心数 = 物理核心数 * 每核逻辑核心数 其中 ...
- 物理CPU,物理核,逻辑CPU,虚拟CPU(vCPU)区别 (转)
在做虚拟化时候,遇到划分CPU的问题,因此考虑到CPU不知道具体怎么划分,查询一些资料后就写成本文. a. 物理CPU:物理CPU是相对于虚拟CPU而言的概念,指实际存在的处理器,就是我们可以看的见, ...
- Linux下判断cpu物理个数、几核
自己服务器的输出 1. 查看物理CPU的个数 #cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l 1 2. 查 ...
- linux下查看cpu物理个数和逻辑个数 - chw1989的专栏 - 博客频道 - CSDN.NET
body { font-family: 微软雅黑,"Microsoft YaHei", Georgia,Helvetica,Arial,sans-serif,宋体, PMingLi ...
- 物理cpu和逻辑cpu
1 物理cpu 插槽里面实际插入的cpu的个数. 通过不重复的physical id可以获取实际的物理cpu的个数. 2 逻辑cpu cat /proc/info processor 1 proces ...
- 物理cpu与逻辑cpu概述
物理cpu与逻辑cpu概述(本博客属于转载部分内容:主要学习目的用于大数据平台Hadoop之yarn资源调度的配置) 一.yarn资源调度器中主要的资源分类 1.memory(内存) 2. ...
- CPU | 物理 CPU vs 逻辑 CPU vs 核心 vs 线程 vs Socket
当我们试着通过 Linux 命令 nproc 和 lscpu 了解一台计算机 CPU 级的架构和性能时,我们总会发现无法正确地理解相应的结果,因为我们会被好几个术语搞混淆:物理 CPU.逻辑 CPU. ...
- SQL SERVER 2005修改数据库名称,包括物理文件名和逻辑名称
SQL SERVER 2005修改数据库名称,包括物理文件名和逻辑名称 原来数据库名称为 aa,物理文件名称为 aa.mdf 和 aa_log.ldf: 需要修改数据库名称为 bb,物理文件名 ...
- CPU相关知识---物理CPU数、物理核数、逻辑核数、逻辑CPU数 ?
一.物理CPU数.物理核数.逻辑核数.逻辑CPU数 相互关系??? 物理CPU数 ---> 每个物理CPU对应物理核数 ---> (每个物理核数对应逻辑核数)物理CPU对应逻辑核数 --- ...
随机推荐
- osx使用alfred集成有道查词
概述 使用 mac 的同学应该经常会使用 alfred 这个软件, 主要能随时能够通过一个快键键打开查询窗口, 方便的搜索或打开软件, 文件等等, 同时也可以集成脚本方便实现其它的功能. 在日常使用的 ...
- 关于移动端使用echarts点击图标外部不能关闭tooltip的问题
新建一个mixin文件 粘贴如下代码: 1 /** 2 * 1. 需要将echart实例赋值为 this.echartsInstance `echartsInstance` echarts 带s 3 ...
- brew基本操作指南
brew安装: /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)&q ...
- Vue js引用警告 “export ‘default‘ (imported as ‘xxx‘) was not found
问题原因:ES6 编译器识别问题 如果在public.js这样写会有警告export 'default' (imported as 'xxx') was not found export const ...
- Linux:touch 修改文件的时间
修改本文件的时间 参数 描述 例子 -a 只修改访问时间(Access Time) touch -a hello.txt -m 只更新修改时间(Modify Time) touch -m hello. ...
- Canvas:绘制文本
基础 画布除了绘制图形以外还可以绘制文本,画布中的文本可以设置字体大小.字体格式.对齐方式(横向和纵向对齐方式),并且还可以制作很炫酷的文本,比如渐变文字. 文本有以下三个属性,控制文本的字体大小.字 ...
- Spring、SpringMVC的区别
Spring是IOC和AOP的容器框架,SpringMVC是基于Spring功能之上添加的Web框架,想用SpringMVC必须先依赖Spring.简单点的话可以将SpringMVC类比于Struts ...
- 【面试题】ES6语法五之箭头函数
ES6特性=>. function foo(x, y){ return x + y } var foo = (x, y) => x + y 包括一个参数列表(零个或多个参数,如果参数不是一 ...
- Wifi Display
wifi display常用术语 AP:wifi access point Primary Sink: a device that supports rendering video content o ...
- 2022-05-07内部群每日三题-清辉PMP
1.项目需要一位熟练的工程师来执行某个特定任务,但由于工作量大,该工程师不能参与这个项目.项目经理下一步应该怎么做? A.修改进度计划,以适应该资源 B.与职能经理协商该资源的参与 C.培训项目团队中 ...