How to view multi-core load situation "go" under Linux

Source: Internet
Author: User
Tags valgrind

The recent server load over load, the CPU of a single charge utilization rate of 80% or 90%, memory consumption is very large, to detect performance, not to the source, only a +-G compiler generated execution files, fuck!!! 1, in Linux downloaded Valgrind, using the Valgrind command respectively for memory use and Suricata kill, after the initialization of the end process after the memory leak, and source-related disclosure of large data blocks for research and positioning;2, we observe the memory usage of the corresponding process number under/proc/, use of each thread stack, the use of global variables and static variables are analyzed briefly; (refer to the articles reproduced earlier)

3, of course, before doing a part of the work, analyzed the top-1, and see the main process of the operation of the various threads, see the use of the core;

How to view multi-core workloads under Linux first of all, the source: Sam's Technical bloghttp://blog.sina.com.cn/samzhen1977

1. Under Linux, how to see the usage per CPU:

#top-D 1

(The system load display is refreshed at 1s, and you can see the total CPU load and the highest CPU process ID, process name, etc.)

(Toggle Press the number 1, you can switch between displaying multiple CPUs and the total CPU)

Then press the number 1. Display multiple CPUs (top and press 1)

Cpu0:1.0%us, 3.0%sy, 0.0%ni, 96.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Cpu1:0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st

Here the us,sy,ni,id,wa,hi,si,st are explained separately:

The US column shows the percentage of CPU time that is spent in user mode. When the value of us is higher, the user process consumes more CPU time, but if the long-term is greater than 50%, you need to consider optimizing the user's program.

The SY column shows the percentage of CPU time that the kernel process spends. Here US + SY reference value is 80%, if us+sy greater than 80% indicates that there may be insufficient CPU.
The NI column shows the percentage of CPU that has changed priority within the user's process space.

The ID column shows the percentage of time that the CPU is in an idle state.

The WA column shows the percentage of CPU time consumed by IO waits. Here WA has a reference value of 30%, if WA is more than 30%, it indicates that the IO wait is serious, this may be caused by a lot of random access to disk, or the bandwidth bottleneck of disk or disk access controller (mainly block operation).

Hi

Si

St

2. Under Linux, how to confirm that it is multicore or multi-CPU:

#cat/proc/cpuinfo

Multi-core or multi-CPU if there are multiple projects similar to the following:

processor:0

......

Processor:1

3. How to see which CPU a process is running on:

#top-D 1

Then press f to enter the top Current fields Settings page:

Checked: J:p = Last used CPU (SMP)

One more item: P shows which CPU is used by this process.

Sam has been tested to find that the same process, at different times, uses different CPU cores. This should be Linux Kernel SMP processing.

4. Configure the Linux kernel to support multi-core:

The CONFIG_SMP option must be enabled during kernel configuration to make the kernel aware of SMP.

Processor type and features---> Symmetric multi-processing support

See if the current Linux kernel supports (or uses) SMP

#uname-A

5. Kernel 2.6 for SMP load balancing:

When creating tasks in an SMP system, these tasks are placed in a given CPU run queue. In general, we have no way of knowing when a task is short-lived and when it needs to run long. Therefore, the initial task-to-CPU allocation may not be ideal.

To maintain the balance of task load between CPUs, tasks can be redistributed: moving tasks from a load-heavy CPU to a lightly loaded CPU. The Linux 2.6 version of the scheduler uses load balancing (balancing) to provide this functionality. Every 200ms, the processor checks whether the CPU load is unbalanced, and if unbalanced, the processor will perform a task balancing operation between the CPUs.

A bit of a negative impact of this process is that the cache of the new CPU is cold for the migrated task (the data needs to be read into the cache).

Remember that the CPU cache is a local (on-chip) memory that provides faster access than system memory. If a task is performed on a CPU, the data associated with the task is placed in the local cache of the CPU, which is called hot. If there is no data in the CPU's local cache for a task, the cache is called cold.

Unfortunately, keeping the CPU busy can occur when the CPU cache is cold for the migrated task.

6. How the application leverages multi-core:

Developers can write parallel code to threads that are scheduled to run concurrently by the SMP operating system.

In addition, Sam envisions code that must be executed sequentially. You can divide it into multiple nodes, one thread for each node. and a channel between nodes. Nodes are shaped like pipelines. This can also greatly enhance CPU utilization.

For example:

A game can be divided into 3 nodes.

1. Accepting external information, claiming data (1ms)

2. Using data, physical operations (3MS)

3. Display the results of the physical operation. (2ms)

If linear programming, the entire process requires 6ms.

But if you use each node as a thread. But the thread also executes synchronously. The entire process requires only 3ms.

This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/chenggong2dm/archive/2011/01/12/6131052.aspx

How to view multi-core load situation "go" under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.