[Diary] synchronization I/O write issues found during a program optimization. Remember to tune I/O.

Source: Internet
Author: User

[Diary] synchronization I/O write issues found during a program optimization. Remember to tune I/O.

As we all know, when writing a program, it is a good habit to log important code. To monitor program running performance and record possible errors.

However, if the log is based on synchronous I/O file operations, you must consider the total number of accesses or the number of concurrent operations.

If the total number of times or concurrency is very large, such as 10 W or 1 K/s or more, you must pay attention to the slow effect of IO synchronization performance on program speed.

At this time, it is necessary to use Asynchronous or NIO log class libraries to write logs.



Below is part of my code for scanning out-of-date files on the server and clearing them to other locations. Logs are synchronously written to IO.

Before getting off work, I tested it. I felt that the speed was always a bit wrong. Later I was found to be caused by the synchronous write IO of the log class library (here this function has been accessed frequently and intensive operations.

Record it. Do not forget it later.

 

Note the program execution speed comparison before and after synchronizing IO Log Code, as shown below:

Before and after, the program running speed is quite different

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.