Issue found by the performance team.
At the end of a marking cycle, we know how much reclaimable space there is in each of the old regions. We also know which old regions are reasonable candidates for collection during the next mixed GC phase.
At the end of the next young GC (i.e. the first young to complete after marking), and each subsequent mixed GC, the amount of reclaimable space is checked to see if it's above G1HeapWastePercent. If it is then the next GC will be a mixed GC.
During a mixed GC, we add a number of old regions to the collection set at the start of the collection. The number of regions we add is (currently) based upon the values for G1MixedGCCountTarget and G1OldCSetRegionThresholdPercent. Ideally we would like to collect all of the reasonable candidate regions within G1MixedGCCountTarget mixed GCs but we limit the number of old regions in each mixed GC to be 10% of the heap.
At the start of the final mixed GC, the amount of reclaimable space is still above G1HeapWastePercent, and we will add the same number of regions as in the preceding mixed GCs but that number of regions may result in an amount of reclaimable space that is significantly below G1HeapWastePercent and may result in a mixed GC that is very expansive.
We should be monitoring the amount of uncollected reclaimable bytes while we're adding old regions to the collection set and stop when that amount goes below G1HeapWastePercent.