Term: fiber is not a lightweight thread

Source: Internet
Author: User

According to Eric eilebrecht's blog, the fiber does not reduce the memory overhead or have better performance. When we need to use a large number of threads (such as more than 100), the total overhead of stack space of each thread increases linearly, and the overhead of thread switching takes too much time, it may even exceed the overhead of program execution. At this time, we need to design a management mechanism similar to the thread pool, and use a small number of threads to allocate and execute many tasks. Fiber is the implementation of a set of such mechanisms provided by the system, saving us the trouble of designing and making ourselves.

Therefore, each fiber still has its own stack and does not reduce memory overhead. However, multiple fiber threads may be executed on the same thread, that is, the fiber does not have its own Thread Local Storage and static variables, any code dependent on them cannot be executed normally in the fiber path.

Therefore, fiber is only useful in some extreme situations, such as SQL Server, and the cost for general situations is generally far greater than the benefits.

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.