So far I know that:
My Questions are:
Haven't found any documentation on this.
I'm very far from an expert on the JDK's codebase but I believe most of your answers will be around the classes I mention. I'm wild guessing from a cursory read, and very glad to hear corrections.
Question 1:
According to http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/87ee5ee27509/src/share/vm/gc_implementation/shared/ageTable.cpp L81 and next (compute_tenuring_threshold) the JVM will iterate through each age and add up the size of objects with that age. As soon as it exceeds the desired_survivor_size it'll stop and assume the last age it got to as the candidate new threshold. The chosen new threshold is min(candidateAge, MaxTenuringThreshold)
compute_tenuring_threshold is called in G1 from http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/87ee5ee27509/src/share/vm/gc_implementation/shared/g1CollectorPolicy.cpp which choses a _max_survivor_regions based on ceil(_young_list_target_length / SurvivorRatio), then calls the compute_.. method above.
The young_list_target_length is updated in g1CollectorPolicy.hpp as explained:
587 // Update the young list target length either by setting it to the
588 // desired fixed value or by calculating it using G1's pause
589 // prediction model. If no rs_lengths parameter is passed, predict
590 // the RS lengths using the prediction model, otherwise use the
591 // given rs_lengths as the prediction.
592 void update_young_list_target_length(size_t rs_lengths = (size_t) -1);
I didn't look into the model, but I guess this would answer your question: threshold changes are triggered after a lower number of ages is enough to keep the desired_survivor_size (which AFAIK is explained here http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html). The new threshold is chosen based on given / predicted RS lengths.
Question 2:
Check this in g1CollectorPolicy.cpp, right at the start of a new collection pause:
839 // We only need to do this here as the policy will only be applied
840 // to the GC we're about to start. so, no point is calculating this
841 // every time we calculate / recalculate the target young length.
842 update_survivors_policy();
I understand that the threshold will thus be updated before the GC runs. If that's the case, as live objects in survivor regions are visited, all objects that have object.age > newAge will be tenured (including those that had age < threshold at timestamp1 but now exceed it).
I hope that makes a bit of sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With