In the context of a soft real-time system that should not stop for more than 200 ms, we are looking for a way to get a warning before the full GC appears. We understand that we may not be able to avoid this, but we would like to switch to another node before the system crashes.
We were able to devise a scheme that would give us a preliminary warning, in front of the inevitable full GC, which could lead to a system shutdown in a few seconds (which we need to avoid).
What we could find depends on the statistics of free lists CMS: -XX:PrintFLSStatistics=1 . This prints the statistics of the free list to the GC log after each GC cycle, including the young GC, so the information is available at short intervals and will appear even more often during periods of high speed memory allocation. It probably costs a little in terms of performance, but our working assumption is that we can afford it.
Logging out is as follows:
Statistics for BinaryTreeDictionary: ------------------------------------ Total Free Space: 382153298 Max Chunk Size: 382064598 Number of Blocks: 28 Av. Block Size: 13648332 Tree Height: 8
In particular, the maximum size of a free fragment is 382064598 words. With 64-bit words, this should be just below 2915 MB. This number decreased very slowly, at a speed of about 1 MB per hour.
In our opinion, as long as the maximum size of a free piece is larger than the younger generation (provided that a mixture of objects is not highlighted), each promotion of the object must be successful.
We recently conducted stress tests for several days and saw that the CMS was able to maintain maximum block sizes above 94% of the total space of the old region. The maximum free block size decreases with a speed of less than 1 MB / hour, which should be good - in accordance with this, we will not fully hit the full GC in the near future, and the servers will most likely be unavailable for maintenance often than the full GC can happen.
In the previous test, when the system was less efficient in terms of memory, we were able to start the system within 10 hours. During the first hour, the maximum size of a free piece decreased to 100 MB, where it remained for more than 8 hours. Over the past 40 minutes of run, the maximum free piece size decreased at a constant speed to 0 when a full GC occurred - it was very encouraging because for this workload we seemed to get a 40-minute advance warning (when the block size started steady decrease towards 0).
My question is for you . Assuming all this reflects the long-term maximum workload (the workload at any given time in production will only be lower), does this seem like the right approach? With what degree of reliability do you think that we can count on the maximum statistics of the size of a free piece from the GC magazine?
We are definitely open to suggestions, but we ask that they be limited to the solutions available for HotSpot (without Azul for us, at least for now). In addition, G1 alone is not a solution unless we get a similar metric that gives us a preliminary warning before full GCs or any GCs that significantly exceed our SLA (and this can happen sometimes).