In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to achieve JVM tuning". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's ideas to study and learn "how to achieve JVM tuning".
I put the main structure and parameters of the stack area below so that I can refer to the figure:
First, how to set the maximum age
Every time a Young GC occurs, the surviving objects in the Eden area and the current Survivor area are transferred to another Survivor area at one time, and the previous Eden area and Survivor area are emptied. So the surviving objects of the younger generation basically switch back and forth between the two Survivor areas, and each time they change, their age increases by one year. When the maximum age is reached (the maximum age is set by the-XX:MaxTenuringThreshold parameter, the default is 15 years old), it will be transferred to the old age.
Now there is a scene where there are 1000 8-year-olds, and after a period of time, there are 900 15-year-olds. It can be observed that after the age of 8, 90% of the objects reach the default maximum age, and these objects are constantly moving back and forth between the two Survivor zones, undoubtedly increasing the replication cost. Therefore, in this case, we can set the maximum age to 8 years old, and transfer directly to the old age, so as to avoid repeated replication and waste of space of the new generation.
Second, what if Young GC is frequent?
We use jstat-gcutil {pid} 1000, which prints out GC statistics per second, where YGC represents the total number of Young GC occurrences. Refresh the statistics once a second, if you find that YGC increases frequently, such as Young GC once a second.
Young GC is frequent, which means that the creation speed of new objects does not match the size of the new generation, either the frequent creation of objects in the code, or the space of the new generation is too small. It is necessary to review the code, but it is very time-consuming. So this time, we mainly start with the plan of adjusting the size of the new generation.
We can increase the Cenozoic area to 1.5 times (why 1.5 times, which is just a multiple of temptation). If the previous 1000ms of Young GC occurs every other time, then theoretically, the occurrence interval of the current Young GC is about 1500ms, and the frequency decreases somewhat, but will it increase the time consuming of each Young GC by 1.5 times?
The answer is no.
Young GC mainly cleans up the Cenozoic era, first marks the surviving objects in Eden area and one Survivor area, then copies another Survivor area together, and finally cleans up Eden area and previous Survivor area directly. It can be seen that the most time-consuming link here is the replication operation.
About 98% of objects die within milliseconds. Even if the new generation is expanded to 1.5 times that of the original, then when the next Young GC arrives, the total number of replicated objects will be far less than 1.5 times, perhaps only a little more than before, such as 1.15 times.
Therefore, if the capacity of the new generation is expanded to 1.5 times that of the original, theoretically, the scanning time of the new generation will become 1.5 times that of the original, the marking time will be within 1.5 times, and the replication time will be within 1.5 times, and the two times will be much less than 1.5 times. For virtual machines, the cost of replication is much greater than scanning and marking operations. Therefore, after the expansion of the Cenozoic generation, Young GC will not increase significantly in a linear manner.
If the size of the entire heap remains the same, then the expansion of the new generation is bound to compress the space of the old era, and the frequency of Major GC may increase. Therefore, we still need to find a critical point, when the frequency of Young GC can be greatly reduced, and only increase the frequency of Major GC in a small range.
Thank you for reading, the above is the content of "how to achieve JVM tuning", after the study of this article, I believe you have a deeper understanding of how to achieve JVM tuning, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.