New Tricks: Extreme Optimization of Linux Startup time

Source: Internet
Author: User
Article Title: Newbie: Extreme Optimization of Linux Startup time. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

(1) first, tracking and analyzing the Linux Startup Process and generating a detailed startup time report.

The simple and feasible method is to add a timestamp for all kernel information during the startup process through the PrintkTime function, which facilitates summary and analysis. PrintkTime was one of the earliest Kernel patches provided by CELF and was formally incorporated into the standard Kernel in later Kernel 2.6.11. Therefore, you may directly enable this function in the new kernel version. If your Linux kernel cannot be updated to Versions later than 2.6.11 for some reason, you can refer to the methods provided by CELF to modify or directly download the patches they provide: http://tree.celinuxforum.org/CelfPubWiki/PrintkTimes

You can simply enable the PrintkTime function by adding "time" to the kernel startup parameters. Of course, you can also choose to directly specify "Show timing information on printks" in "Kernel hacking" during Kernel compilation to force the timestamp to be added to the Kernel information at each startup. This method also has another advantage: You can get all the information of the kernel before parsing the startup parameter. Therefore, I chose the next method.

After completing the preceding configuration, restart Linux and run the following command to output the kernel startup information to the file:

Dmesg-s 131072> ktime

Then, use the script "show_delta" (located in the scripts folder of the Linux Source Code) to convert the output file to the time increment display format:

/Usr/src/linux-x.xx.xx/scripts/show_delta ktime> dtime

In this way, you get a detailed report on Linux Startup time consumption.

(2) then, we will use this report to find out the relatively time-consuming process during startup.

It must be clear that there is no necessary correspondence between the time increment and kernel information in the report. The real time consumption must be analyzed from the kernel source code.

This is not difficult for a friend who is a little familiar with programming, because the time increment is only the time difference between two calls to printk. Generally, during kernel startup, some time-consuming tasks, such as creating hash indexes and probe hardware devices, are printed through printk. In this case, the time increment usually reflects the time consumed by the information-related process. However, in some cases, the kernel starts the corresponding process only after the printk output information is called, in the report, the time consumed for the corresponding kernel information process corresponds to the time increment of the next line. In other cases, the time is consumed in an uncertain period between two kernel information outputs, in this way, the time increment may be completely unable to be reflected through the kernel information.

Therefore, in order to accurately determine the real time consumption, we need to analyze it with the kernel source code. When necessary, for example, in the third case above, You have to insert printk printing in the source code to further determine the actual time consumption process.

The Linux kernel startup analysis after my last reduction is as follows:

Total kernel Start Time: 6.188 s

Key time-consuming part:

1) initialization of core components such as 0.652 s-Timer, IRQ, Cache, And Mem Pages

2) 0.611 s-kernel and RTC Clock Synchronization

3) 0.328 s-computing Calibrating Delay (total consumption of 4 CPU cores)

4) 0.144 s-calibration APIC clock

5) 0.312 s-calibration Migration Cost

6) 3.520 s-Intel E1000 Nic Initialization

Next, we will analyze and resolve the above parts one by one.

[1] [2] Next page

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.