-
此CPU设置并发线程数多少最合适?5
cpuinfo如下:
cpuinfo: processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU L5630 @ 2.13GHz stepping : 2 cpu MHz : 2134.000 cache size : 12288 KB physical id : 0 siblings : 8 core id : 0 cpu cores : 4 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 4266.49 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU L5630 @ 2.13GHz stepping : 2 cpu MHz : 2134.000 cache size : 12288 KB physical id : 0 siblings : 8 core id : 1 cpu cores : 4 apicid : 2 initial apicid : 2 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 4266.49 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 2 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU L5630 @ 2.13GHz stepping : 2 cpu MHz : 1600.000 cache size : 12288 KB physical id : 0 siblings : 8 core id : 9 cpu cores : 4 apicid : 18 initial apicid : 18 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 4266.49 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 3 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU L5630 @ 2.13GHz stepping : 2 cpu MHz : 2134.000 cache size : 12288 KB physical id : 0 siblings : 8 core id : 10 cpu cores : 4 apicid : 20 initial apicid : 20 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 4266.49 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 4 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU L5630 @ 2.13GHz stepping : 2 cpu MHz : 1600.000 cache size : 12288 KB physical id : 1 siblings : 8 core id : 0 cpu cores : 4 apicid : 32 initial apicid : 32 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 4266.58 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 5 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU L5630 @ 2.13GHz stepping : 2 cpu MHz : 2134.000 cache size : 12288 KB physical id : 1 siblings : 8 core id : 1 cpu cores : 4 apicid : 34 initial apicid : 34 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 4266.58 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management:
请详细解释一下该机器的CPU信息,以及并发线程数设置多少最佳?
谢谢!2013年6月17日 14:06
4个答案 按时间排序 按投票排序
-
对于计算密集型任务,在拥有Ncpu个处理器的系统上,当线程池大小为N+1时,通常能实现最优的利用率,(即当计算密集型任务偶尔由于页缺失故障或者其他原因而暂停时,这个额外的现线程也能够确保CPU的时钟周期不会被浪费。)
对于包含IO操作或者其他阻塞操作的任务,由于线程并不会一直执行,因此线程池的规模应该更大.要正确的设置线程池的大小,你必须估算出任务的等待时间和计算时间的比值。这种估算不需要很精确,并且可以通过一些分析活监控工具老获得。
还可以通过另外一种方法来调节线程池的大小,在某个基准负载下,分别设置不同大小的线程池来运行应用程序,并观察CPU的利用水平。
Ncpu = number of CPUs
Ucpu = target CPU utilization, 0 <= Ucpu <= 1
W
- = ratio of wait time to compute time
C
要使处理器达到期望的利用率,线程池的最优大小为:
Nthreads = Ncpu * Ucpu * (1 + W/C)
参考<<java concurrency in practise>> P1412013年6月18日 21:23
-
3DNOW A multimedia extension created by AMD for its processors, based on / almost equivalent to Intel’s MMX extensions
3DNOWEXT 3DNOW Extended. Also known as AMD’s 3DNow!Enhanced 3DNow!Extensions
APIC Advanced Programmable Interrupt Controller
CLFSH/CLFlush Cache Line Flush
CMOV Conditional Move/Compare Instruction
CMP_Legacy Register showing the CPU is not Hyper-Threading capable
Constant_TSC on Intel P-4s, the TSC runs with constant frequency independent of cpu frequency when EST is used
CR8Legacy -unknown-
CX8 CMPXCHG8B Instruction. (Compare and exchange 8 bytes. Also known as F00F, which is an abbreviation of the hexadecimal encoding of an instruction that exhibits a design flaw in the majority of older Intel Pentium CPU).
CX16 CMPXCHG16B Instruction. (CMPXCHG16B allows for atomic operations on 128-bit double quadword (or oword) data types. This is useful for high resolution counters that could be updated by multiple processors (or cores). Without CMPXCHG16B the only way to perform such an operation is by using a critical section.)
DE Debugging Extensions
DS Debug Store
DS_CPL CPL qualified Debug Store (whatever CPL might mean in this context)
DTS Could mean Debug Trace Store or Digital Thermal Sensor, depending on source
EIST/EST Enhanced Intel SpeedsTep
EPT extended Page Tables (Intel, similar to NPT on AMD)
FXSR FXSAVE/FXRSTOR. (The FXSAVE instruction writes the current state of the x87 FPU, MMX technology, Streaming SIMD Extensions, and Streaming SIMD Extensions 2 data, control, and status registers to the destination operand. The destination is a 512-byte memory location. FXRSTOR will restore the state saves).
FXSR_OPT -unknown-
HT Hyper-Transport. Note that the same abbreviation might is also used to indicate Hyper Threading (see below)
HTT/HT Hyper-Threading. An Intel technology that allows quasi-parallel execution of different instructions on a single core. The single core is seen by applications as if it were two (or potentially more) cores. However, two true CPU cores are almost always faster than a single core with HyperThreading. This flag indicates support in the CPU when checking the flags in /proc/cpuinfo on Linux systems. For more info how you can detect active HyperThreading, see the first comment in my blog post about this page at [2]
HVM Hardware support for virtual machines (Xen abbreviation for AMD SVM / Intel VMX)
LAHF_LM Load Flags into AH Register, Long Mode.
LM Long Mode. (64bit Extensions, AMD’s AMD64 or Intel’s EM64T).
MCA Machine Check Architecture
MCE Machine Check Exception
MMX It is rumoured to stand for MultiMedia eXtension or Multiple Math or Matrix Math eXtension, but officially it is a meaningless acronym trademarked by Intel
MMXEXT MMX Extensions – an enhanced set of instructions compared to MMX
MON/MONITOR CPU Monitor
MSR RDMSR and WRMSR Support
MTRR Memory Type Range Register
NPT Nested Page Tables (AMD, similar to EPT on Intel)
NX No eXecute, a flag that can be set on memory pages to disable execution of code in these pages
PAE Physical Address Extensions. PAE is the added ability of the IA32 processor to address more than 4 GB of physical memory using Intel’s 36bit page addresses instead of the standard 32bit page addresses to access a total of 64GB of RAM. Also supported by many AMD chips
PAT Page Attribute Table
PBE Pending Break Encoding
PGE PTE Global Bit
PNI Prescott New Instruction. This was the codename for SSE3 before it was released on the Intel Prescott processor (which was later added to the Pentium 4 family name).
PSE Page Size Extensions. (See PSE36)
PSE36 Page Size Extensions 36. IA-32 supports two methods to access memory above 4 GB (32 bits), PSE and PAE. PSE is the older and far less used version. For more information, take a look at [1].
SEP SYSENTER and SYSEXIT
SS Self-Snoop
SSE Streaming SIMD Extensions. Developed by Intel for its Pentium III but also implemented by AMD processors from Athlon XP onwards
SSE2 Streaming SIMD Extensions 2. (An additional 144 SIMDs.) Introduced by Intel Pentium 4, on AMD since Athlon 64
SSE3 Streaming SIMD Extensions 3. (An additional 13 instructions) introduced with “Prescott” revision Intel Pentium 4 processors. AMD introduced SSE3 with the Athlon 64 “Venice” revision
SSSE3 Supplemental Streaming SIMD Extension 3. (SSSE3 contains 16 new discrete instructions over SSE3.) Introduced on Intel Core 2 Duo processors. No AMD chip supports SSSE3 yet.
SSE4 Streaming SIMD Extentions 4. Introduced with “Nehalem” processor in 2008. Also known as “Nehalem New Instructions (NNI)”
SSE4_1 Streaming SIMD Extentions 4.1
SSE4_2 Streaming SIMD Extentions 4.2
SVM Secure Virtual Machine. (AMD’s virtualization extensions to the 64-bit x86 architecture, equivalent to Intel’s VMX, both also known as HVM in the Xen hypervisor.)
TM Thermal Monitor
TM2 Thermal Monitor 2
tpr_shadow Shadowed Task Priority Registers (for virtualization)
TSC Time Stamp Counter
VME Virtual-8086 Mode Enhancement
VMX Intel’s equivalent to AMD’s SVM
VNMI virtual NMI (non-maskable interrupts) (for virtualization)
VPID Virtual Processor ID (for virtualization)
XTPR TPR register chipset update control messenger. Part of the APIC code2013年6月17日 19:48
相关推荐
在多任务或多线程环境下,了解CPU支持的最大线程数至关重要,因为它直接影响到系统能够并发处理的工作量。"获取本机CPU支持的最大线程数"这个工具正是为了帮助用户快速、方便地获取这一信息。 首先,我们要理解什么...
在实际应用中,针对高并发且任务执行时间短的业务,线程池线程数通常设置为CPU核数+1,以减少线程上下文切换的开销。对于并发不高但任务执行时间较长的情况,需要区分任务类型。如果是IO密集型,可以适当增加线程数...
这可能包括模拟视频帧,使用合适的编码格式(如H.264),然后通过多线程并发发送到多个目的地。 5. **同步与互斥量(Mutexes and Semaphores)**:在多线程环境中,为了保证数据的一致性和完整性,我们需要使用同步...
在IT行业中,多线程并发处理数据是一种常见的优化策略,特别是在大数据处理、网络服务和分布式系统中。通过并发,可以充分利用多核处理器的计算能力,提高程序执行效率,缩短任务的总体完成时间。本篇文章将深入探讨...
- **线程划分尺度**:线程比进程更轻量级,这使得多线程程序能够更加高效地利用CPU资源,提高并发性。 #### 三、创建多线程的方法 创建多线程的常见方法有三种: 1. **继承Thread类**:通过继承`Thread`类并重写`...
- **CPU密集型任务**:这类任务主要依赖CPU计算,线程数应与CPU核心数相当,通常设置为CPU核心数+1,以防其他因素导致线程阻塞。 3. **上下文切换成本**: - 上下文切换是操作系统在不同线程之间切换的过程,这个...
在Linux下基于socket多线程并发通信的编程中,多线程并发具有的优势是可以减少CPU被大量占用,提高编程的效率和应用程序响应的速度,促进系统的程序结构进一步优化。在合理运用并发技术的情况下,可以同时完成多个...
然而,由于GIL(全局解释器锁)的存在,Python的多线程在CPU密集型任务上并不能充分利用多核资源,但在I/O密集型任务中,如爬虫,仍可以并发执行请求,提高效率。需要注意的是,线程间的同步和竞争条件也需要谨慎...
此设置决定了同一时间可以有多少个客户端连接到SQL Server实例。了解并正确配置这个参数对于数据库管理员来说至关重要,因为它直接影响到系统的并发处理能力、资源管理和用户体验。 1. **最大连接数的意义**: - ...
3. 管程:Java中的Semaphore、CountDownLatch、CyclicBarrier等同步工具,用于控制并发线程的数量或协调线程执行。 三、并发容器 1. 原生容器:ArrayList、LinkedList等不保证线程安全,而Vector、Stack则是线程...
在Java编程中,多线程是一种常见的并发处理方式,它能充分利用CPU资源,提高程序的执行效率。本示例主要探讨了如何通过两种方法来控制Java中的线程数量,以达到优化性能和防止内存不足的目的。 首先,我们来看...
Executor框架是Java并发编程中的重要工具,它简化了线程池的管理,例如`CachedThreadPool`、`FixedThreadPool`和`SingleThreadExecutor`,分别对应于动态线程池、固定大小线程池和单线程线程池,可以根据需要选择...
以下示例展示了如何使用线程池和信号量来控制并发线程的数量。 ```python import threading import random import Queue from time import sleep class WorkerThread(threading.Thread): def __init__(self, ...
因此,我们需要对并发线程进行控制。通常,我们可以设定一个合理的最大并发数,比如设备的CPU核心数。这样可以避免过度消耗系统资源,同时保持较好的加载效率。 4. **线程池(ThreadPoolExecutor)**:在Android中...
这是因为系统资源的使用情况(如内存使用量、CPU利用率、服务器进程/线程数、数据库连接数以及网络带宽占用率等)与并发用户数密切相关。然而,在实际工作中,很多人往往依赖主观判断而非科学方法来估计这一数值。...
在Java编程环境中,HBase是一个基于Google Bigtable设计的分布式、高性能、版本化的NoSQL数据库。...在实际开发中,应根据具体场景选择合适的多线程策略,并进行充分的测试和调优,以达到最佳性能。
对于大量并发连接,epoll通常是最佳选择,但在低并发或跨平台需求时,多进程或多线程模式可能更为合适。无论哪种模式,都需要考虑到线程同步、资源管理和错误处理等问题,以确保服务器的稳定性和性能。
### 并发、多线程、同步异步概念解析 #### 一、并发与多线程 **并发**(Concurrency)是指多个任务看起来同时进行的一种现象。在计算机领域,特别是操作系统层面,它指的是一个时间段内有多个程序或任务都在运行...
增加并发连接数可能会增加系统资源的消耗,尤其是在内存和CPU有限的老式计算机上。此外,过高的并发连接数也可能引起网络安全问题,因为恶意软件可能会利用这一点进行攻击。因此,根据个人需求和硬件条件来设定合适...
单线程和多线程是计算机程序执行时的两种不同模型,它们在处理并发任务、资源管理和性能上有着显著的差异。理解这两种模型是编程尤其是服务器端开发的基础,尤其是在Java、C#等支持多线程的编程语言中。 首先,让...