“I don’t have to worry about garbage collection” – Is this true? | Java code geeks

I’ve heard a few of my developer friends say: “Garbage collection is automatic. So I don’t have to worry about it.“The first part is true, that is,“ Garbage Collection is automatic ”on all modern platforms – Java, .NET, Golang, Python… – may not be true. It’s debatable, debatable. Here is my case to show the importance of garbage collection:

1. Unpleasant customer experience

When a garbage collector runs, it interrupts the entire application to mark objects in use and scan objects that do not have active references. During this pause period, all open customer transactions will be blocked (i.e. frozen). Depending on the type of GC algorithm and the memory settings you configure, pause times can range from a few milliseconds to a few minutes. Frequent pauses in the app can cause your clients to stutter, jerk or stop. This will leave an unpleasant experience for your customers.

2. Millions of dollars wasted

Here is a white paper we published, explaining in a factual way how companies waste millions of dollars because of garbage collection. Basically, in a nutshell, modern apps create thousands / millions of objects. These objects should be constantly scanned to determine if they have active references or if they are ready for garbage collection. After the objects are retrieved, the memory becomes fragmented. Fragmented memory must be compacted. All these activities consume *huge calculation cycles*. These calculation cycles translate into millions of dollars in expense. If the performance of the garbage collection can be optimized, it can save millions of dollars.

3. Low risk, high impact performance enhancements

By optimizing the performance of Garbage Collection, you not only improve garbage collection pause time, but you also improve the overall response time of the application. We recently helped refine the garbage collection performance of one of the world’s largest automakers. Just by changing garbage collection settings without refactoring a single line of code, we have significantly improved the overall response time of their application. The table below summarizes the overall improvement in response time we got with each garbage collection setting change we made:

Average response time (seconds) Transactions> 25 seconds (%)
Reference 1.88 0.7
GC Parameters iteration # 2 1.36 0.12
GC settings iteration # 3 1.7 0.11
GC settings iteration # 4 1.48 0.08
GC settings iteration # 5 2.045 0.14
GC settings iteration # 6 1,087 0.24
GC settings iteration # 7 1.03 0.14
GC parameters iteration # 8 0.95 0.31

When we started the GC tuning exercise, the overall response time for this automotive application was 1.88 seconds. As we optimized the performance of garbage collection with different parameters, in iteration # 8 we were able to improve the overall response time to 0.95 seconds. that is to say, 49.46% improved response time. Likewise, the percentages of transactions longer than 25 seconds fell from 0.7% to 0.31%, an improvement of 55%. This is a significant improvement to be made without modifying a single line of code.

All other forms of response time improvement will require an infrastructure change or architectural change, or code level changes. All are costly changes. Even if you embark on these expensive changes, there is no guarantee of improving the response time of the application.

4. Predictive surveillance

Waste collection logs expose vital predictive micrometries. These metrics can be used to forecast the availability and performance of the application. One of the micrometries exhibited in Garbage Collection is’GIC Debit‘(to learn more about other micrometries, see to this article). What is GC Throughput? If your application’s GC throughput is 98%, that means your application is spending 98% of its time processing client activity and the remaining 2% on GC activity. When the application suffers from a memory problem, several minutes before the GC throughput begins to degrade. Troubleshooting tools like yCrash monitors “GC throughput” to predict and predict memory problems before they occur in the production environment.

5. Capacity planning

When planning your application capacity, you need to understand your application’s demand for memory, CPU, network, and storage. One of the best ways to study memory demand is to analyze the behavior of the garbage collector. When you analyze the behavior of garbage collection, you can determine the average object creation rate (example: 150MB / s), the average object recovery rate. By using this type of micrometry, you can effectively plan the capacity of your application.


Friends, in this article I have done my best to justify the importance of garbage collection analysis. I wish you and your team the best in benefiting from the highly relevant metrics of garbage collection.

Source link