In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > IT Information >
Share
Shulou(Shulou.com)11/24 Report--
This article comes from the official account of Wechat: programming Technology Universe (ID:xuanyuancoding), author: Xuanyuan Wind O
Memory access bottleneck I am Ah Q from CPU No.1 workshop. A great event happened in our factory not long ago. The boss got an investment and was ready to expand the production scale.
However, the boss is very stingy, even if he gets the investment, he doesn't give us a raise, so he knows that he makes us work hard and squeeze our labor force.
The boss said that the investment money should be used to buy equipment and recruit new employees. We already have eight workshops, but this time we have directly double, and it has become sixteen! If only our wages could be double.
Now we have become a 16-core CPU!
Originally thought that our production efficiency can also double, but unexpectedly encountered new problems.
All workshops in our CPU have to access memory through memory controllers and bus systems. Sometimes when we encounter several workshops to access memory, we have to compete.
In the past, the competition in our eight workshops was not very fierce, so we were just modest to each other. Now that all sixteen workshops have to cross the log bridge, the competition will be fierce, especially since we old employees will not give way to newcomers, and unhappiness often occurs in order to do so.
There is a bottleneck in memory access, and this performance is naturally severely compromised.
The boss of NUMA architecture saw all this in his eyes and privately asked me, Huzi of No.2 workshop and the bus director for a small meeting.
"you are all the core employees of the factory. What do you think of the current problems in the factory?" The boss asked us how many.
Huzi and I looked at each other and didn't talk.
At this time, the bus director said, "Boss, the problem now is that there is only one way to access memory, and everyone has to squeeze, which will inevitably cause friction and affect work performance." if you want to solve the problem fundamentally, you'd better build another road. "
"what do you mean by building another road?"
"I propose to separate the eight newly expanded workshops and build a branch factory. Then divide the memory and let each of the two factories manage part of it. On the one hand, it can reduce the contradiction between new and old employees, and on the other hand, it can reduce the waste of resources caused by memory congestion. Besides, if the scale continues to expand in the future, you can continue to use this method," the bus director continued.
The leader was bowing his head and thinking, but I thought of a question: "Director, what if the memory page to be accessed by the thread executed by our No. 1 core is not on the memory managed by our factory?"
"well, in that case, the two factories need to communicate with each other, and if the memory accessed is not within their jurisdiction, they have to help each other pass it on."
The boss patted the table and said, "good idea! let's do it!"
The next day, the boss summoned representatives from 16 workshops, the bus director, and Xiao Li, the memory management representative from the operating system, to hold a meeting together, at which the new technical proposal was formally adopted.
There is also a name for this technology: NUMA (Non Uniform Memory Access), inconsistent memory access.
The existing 16 workshops are split into two CPU factories called two NUMA nodes (Node). Each node is directly connected to part of the memory, and there is a special inter-connect channel between the two nodes. Each node directly accesses the memory managed by itself is called Local Access, and the memory managed by other factories through inter-connect channel is called Remote Access. Obviously, the access speed of the former is much faster than that of the latter, so this is the origin of the name of this technology: inconsistent memory access.
After the adjustment of the new organizational structure, the work efficiency of the factory has been improved a lot, and there are many fewer contradictions and frictions, so we can work happily again.
The operating system supports the adjustment of our organizational structure, and the operating system is very busy. In order to support our new architecture, the operating system has to make some adjustments.
First of all, there is the problem of caching. The process-thread scheduling management department of the operating system needs to pay attention not to schedule threads across NUMA nodes as far as possible, and can not let a thread run in the next factory and then in our factory, so that the established cache is invalid.
There is also the issue of memory affinity. In order to get faster memory access, the memory management department of the operating system has formulated a memory allocation strategy. Which NUMA node the thread executes, then allocate the memory to the memory directly connected to that node to avoid cross-node memory access.
Not to mention, with such an optimization and adjustment of the operating system, the work efficiency has really improved a lot.
However, the good times did not last long, and because of this adjustment, new problems appeared again.
The problem of MySQL recently, a strange thing happened. I don't know what happened. The memory under the jurisdiction of our branch factory was quickly used up, but there was still a lot of space for the memory managed by the factory next door.
The operating system does not allocate the memory pages over there, but allows us to swap the memory pages to the hard disk to vacate the space. We have spent a lot of time on this, which has caused our performance to decline, which is not as good as the newcomers in the branch factory next door.
Finally, one day, I couldn't stand it any longer. Together with some old guys in the factory, I called Xiao Li from the memory management department of the operating system again.
"what's the matter with you? can't you allocate the memory under the jurisdiction of the No.2 node factory next door? obviously there is so much space, but it keeps us busy." I'm a little angry.
Xiao Li said innocently, "to tell you the truth, a few days ago, someone came to our Linux empire to set up a new company called MySQL. This guy is a big memory eater. As soon as he comes up, he will eat dozens of gigabytes of memory. Most of the memory under your factory's jurisdiction has been eaten by it."
Huzi asked, "what does this have to do with us? don't pass the buck."
"Last time I came to a meeting, didn't you build a NUMA architecture? accessing locally connected memory is faster than accessing remote memory, so we have a memory affinity strategy. Which NUMA node the thread executes, allocates memory to which node is directly connected, thinking that this will improve performance," Xiao Li continued aggrieved.
"you can't be stubborn. Although accessing remote memory is not as fast as accessing local memory, it is better than constantly swapping pages from memory and hard disk. You are really good at doing bad things."
As soon as we said this, Xiao Li was also aware of the problem of doing so. "I'll go back and feedback your opinions and adjust our strategy."
After a few days, there is a new memory allocation strategy on the operating system, which allocates memory evenly to each NUMA node, and we no longer have to move data back and forth between memory and hard drives.
NUMA is good, but if you don't use it well, it will only add to your troubles.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.