Can lock free improve performance?

Source: Internet
Author: User

If you don't know how to lock free, read my previous article. The lock free thing is really a twist and controversy. Recently, many Daniel (such as 1 and 2) have been discussing this issue.

Lock free should be of no dispute regarding the solution to the dead/live lock issue, which is indeed the biggest benefit of lock free.

More discussions are focused on algorithm performance. After all, in the multi-core era, multiprogramming mainly solves program performance bottlenecks. Although I personally do not care too much about the impact of lock or lock free on performance, the pursuit of performance is always endless ......

Some previous articles in the image have tested the performance improvement brought about by lock free, as if it can be up4Of course, this number is meaningless. As we all know, the performance problem is affected by too many factors, and the multi-core is more complicated. All in all, it is the result of the combination of software and hardware. However, if the speed can be increased several times in some tests, this should be quite impressive.

However, many discussions (or this) believe that the CPU atomic commands used in lock free still need to be implemented using the same lock mechanism, therefore, the performance should not be improved compared with the direct use of the lock algorithm. I don't agree with this point of view. In terms of concept, commands like cmpxchg can be understood as using a lock internally. In fact, the processor should use a method of locking the bus. We usually talk about the real lock. This is the concept of the operating system layer. It is not very clear about how internal implementation is implemented, however, it is certain that the various lock operations (check, obtain, and release) are very heavyweight compared to a simple atomic command. After all, the lock is more complicated than an atomic command. Therefore, the solution of replacing the system lock with atomic commands should still improve the performance. As for how much to improve, this depends on the specific case, but it should not be the only improvement that can be ignored. Compared with the lock on the OS, atomic commands use hardware to provide special support for concurrency, after all, things with special features are generally more suitable than general solutions (otherwise, they do not need special features ). People who have worked on certain applications (such as video processing) know that they generally use software to simulate and verify a logic, but in the end, they may need to rely on some dedicated circuits to speed up, the truth is a bit similar.

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.