RFR (M): 8074037: Refactor the G1GCPhaseTime logging to make it easier to add new phases

Bengt Rutisson bengt.rutisson at oracle.com
Fri Feb 27 15:38:50 UTC 2015


Hi everyone,

Can I have a couple of reviews for this cleanup change?

http://cr.openjdk.java.net/~brutisso/8074037/webrev.00/
https://bugs.openjdk.java.net/browse/JDK-8074037

This change is in preparation of adding some new phases to the G1 
logging. Currently when a phase for logging parallel work should be 
added you need to:

- add a WorkerDataArray instance variable to G1GCPhaseTimes
- make sure the variable is initialized in the G1GCPhaseTimes constructor
- make sure the variable is reset in the G1GCPhaseTimes constructor
- make sure the variable is verfied in G1GCPhaseTimes::note_gc_end()
- add printing to the G1GCPhaseTimes::print() method
- add a setter method to the G1GCPhaseTimes interface
- call the setter in the code where you want the time to be measured

With the proposed patch this is simplified to:

- add the new phase to the G1GCPhaseTimes::GCPhases enum
- set up the configuration for the phase in the G1GCPhaseTimes constructor
- call the generic phase setter in the code where you want the time to 
be measured

The rest is handled automatically.

The patch also introduces a new class called G1GCPhaseTimesTracker, 
which is a scoped object to simplify time measurements. I've also tried 
to move conversion of times down to when we print the log messages 
instead of when we store them. This removes several "* 1000.0" in the 
code. Eventually I would like to replace os::elapsedTime() with 
os::elapsed_counter(). But that should be done as a separate patch.

Note that this patch does not change what the output looks like at all. 
The logging looks exactly the same for all logging levels.

Thanks,
Bengt






More information about the hotspot-gc-dev mailing list