Testing and analyzing the performance of the Linux operating system thread Library
Source: Internet
Author: User
Linux operating system thread library Performance Test and Analysis-Linux general technology-Linux programming and kernel information, the following is a detailed description. After NPTL becomes the glibc "selected" thread library, many people are concerned about its performance. This article compares NPTL and LinuxThreads, and comprehensively evaluates the impact of hyper-threading, kernel preemption, and other features on thread performance.
I. Preface
In Linux 2.6.x kernel, the improvement of scheduling performance is one of the most striking parts [1]. NPTL (Native Posix Thread Library) [2] uses the new features of the kernel to overwrite the Linux Thread Library, replacing the long-standing and controversial LinuxThreads [3] as the preferred Thread Library for glibc.
What is the performance of NPTL? What are the obvious improvements compared with LinuxThreads? Before fully analyzing NPTL, This article focuses on these two types of thread libraries, as well as the kernel Preemptible and HyperThreading) [4] and other features have been fully evaluated. The results show that NPTL is definitely worth the expectation and use of a large number of server systems.
Ii. Benchmark
1. Test Platform
The hardware platform for this test is inspur NF420R server [7], 4 Hyperthreading-enabled Intel Xeon 2.2G processors, 4G memory. In Linux, The Slackware 9.0 release [8] is selected. The kernel source code used is www.kernel.org.
2. Test: LMBench
Lmbench is a multi-platform open-source benchmark [5] for evaluating the overall performance of the system, but it does not support threads. There are two benchmark: lat_proc used to evaluate the performance of Process Creation and termination, and lat_ctx used to evaluate the overhead of process switching. Lmbench has a good benchmark structure. You only need to modify the specific Target program (such as lat_proc.c and lat_ctx.c) to obtain the performance data of the thread library that we care about by using the lmbench timing and statistics system.
Based on lat_proc and lat_ctx algorithms, this article implements lat_thread and lat_thread_ctx benchmark. In lat_thread, lat_proc is transformed to use thread, and fork () is replaced by pthread_create (), and pthread_join () is used to replace wait (); In lat_thread_ctx, follow the lat_ctx evaluation algorithm (see the lat_ctx manual page) to rewrite the process of creating a process to the creation thread, and still use the pipeline for communication and synchronization.
Lat_thread null
The null parameter indicates that the thread does not perform any actual operations and returns immediately after creation.
Lat_thread_ctx-s # threads
The size parameter is the same as the lat_ctx definition and can represent the thread size (K Data is allocated in actual programming; # the threads parameter is the number of threads, that is, the total number of threads involved in token transmission, which is equivalent to the program load.
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