comparison src/share/vm/runtime/safepoint.hpp @ 1291:4b0f2f4918ed

6933402: RFE: Improve PrintSafepointStatistics output to track cleanup time Summary: Improve the usability of safepoint statistics data. See bug evaluation for more details. Reviewed-by: ysr, dholmes
author xlu
date Wed, 10 Mar 2010 21:42:26 -0800
parents a61af66fc99e
children c18cbe5936b8
comparison
equal deleted inserted replaced
1290:c8a467bf56ad 1291:4b0f2f4918ed
63 _spinning_timeout = 0, 63 _spinning_timeout = 0,
64 _blocking_timeout = 1 64 _blocking_timeout = 1
65 }; 65 };
66 66
67 typedef struct { 67 typedef struct {
68 float _time_stamp; // record when the current safepoint occurs in seconds
68 int _vmop_type; // type of VM operation triggers the safepoint 69 int _vmop_type; // type of VM operation triggers the safepoint
69 int _nof_total_threads; // total number of Java threads 70 int _nof_total_threads; // total number of Java threads
70 int _nof_initial_running_threads; // total number of initially seen running threads 71 int _nof_initial_running_threads; // total number of initially seen running threads
71 int _nof_threads_wait_to_block; // total number of threads waiting for to block 72 int _nof_threads_wait_to_block; // total number of threads waiting for to block
72 bool _page_armed; // true if polling page is armed, false otherwise 73 bool _page_armed; // true if polling page is armed, false otherwise
73 int _nof_threads_hit_page_trap; // total number of threads hitting the page trap 74 int _nof_threads_hit_page_trap; // total number of threads hitting the page trap
74 jlong _time_to_spin; // total time in millis spent in spinning 75 jlong _time_to_spin; // total time in millis spent in spinning
75 jlong _time_to_wait_to_block; // total time in millis spent in waiting for to block 76 jlong _time_to_wait_to_block; // total time in millis spent in waiting for to block
77 jlong _time_to_do_cleanups; // total time in millis spent in performing cleanups
76 jlong _time_to_sync; // total time in millis spent in getting to _synchronized 78 jlong _time_to_sync; // total time in millis spent in getting to _synchronized
77 jlong _time_to_exec_vmop; // total time in millis spent in vm operation itself 79 jlong _time_to_exec_vmop; // total time in millis spent in vm operation itself
78 jlong _time_elapsed_since_last_safepoint; // time elasped since last safepoint
79 } SafepointStats; 80 } SafepointStats;
80 81
81 private: 82 private:
82 static volatile SynchronizeState _state; // Threads might read this flag directly, without acquireing the Threads_lock 83 static volatile SynchronizeState _state; // Threads might read this flag directly, without acquireing the Threads_lock
83 static volatile int _waiting_to_block; // No. of threads we are waiting for to block. 84 static volatile int _waiting_to_block; // number of threads we are waiting for to block
84 85
85 // This counter is used for fast versions of jni_Get<Primitive>Field. 86 // This counter is used for fast versions of jni_Get<Primitive>Field.
86 // An even value means there is no ongoing safepoint operations. 87 // An even value means there is no ongoing safepoint operations.
87 // The counter is incremented ONLY at the beginning and end of each 88 // The counter is incremented ONLY at the beginning and end of each
88 // safepoint. The fact that Threads_lock is held throughout each pair of 89 // safepoint. The fact that Threads_lock is held throughout each pair of
89 // increments (at the beginning and end of each safepoint) guarantees 90 // increments (at the beginning and end of each safepoint) guarantees
90 // race freedom. 91 // race freedom.
91 public: 92 public:
92 static volatile int _safepoint_counter; 93 static volatile int _safepoint_counter;
93 private: 94 private:
94 95 static long _end_of_last_safepoint; // Time of last safepoint in milliseconds
95 static jlong _last_safepoint; // Time of last safepoint
96 96
97 // statistics 97 // statistics
98 static SafepointStats* _safepoint_stats; // array of SafepointStats struct 98 static jlong _safepoint_begin_time; // time when safepoint begins
99 static int _cur_stat_index; // current index to the above array 99 static SafepointStats* _safepoint_stats; // array of SafepointStats struct
100 static julong _safepoint_reasons[]; // safepoint count for each VM op 100 static int _cur_stat_index; // current index to the above array
101 static julong _coalesced_vmop_count;// coalesced vmop count 101 static julong _safepoint_reasons[]; // safepoint count for each VM op
102 static jlong _max_sync_time; // maximum sync time in nanos 102 static julong _coalesced_vmop_count; // coalesced vmop count
103 static jlong _max_sync_time; // maximum sync time in nanos
104 static jlong _max_vmop_time; // maximum vm operation time in nanos
105 static float _ts_of_current_safepoint; // time stamp of current safepoint in seconds
103 106
104 static void begin_statistics(int nof_threads, int nof_running); 107 static void begin_statistics(int nof_threads, int nof_running);
105 static void update_statistics_on_spin_end(); 108 static void update_statistics_on_spin_end();
106 static void update_statistics_on_sync_end(jlong end_time); 109 static void update_statistics_on_sync_end(jlong end_time);
110 static void update_statistics_on_cleanup_end(jlong end_time);
107 static void end_statistics(jlong end_time); 111 static void end_statistics(jlong end_time);
108 static void print_statistics(); 112 static void print_statistics();
109 inline static void inc_page_trap_count() { 113 inline static void inc_page_trap_count() {
110 Atomic::inc(&_safepoint_stats[_cur_stat_index]._nof_threads_hit_page_trap); 114 Atomic::inc(&_safepoint_stats[_cur_stat_index]._nof_threads_hit_page_trap);
111 } 115 }
138 142
139 // Exception handling for page polling 143 // Exception handling for page polling
140 static void handle_polling_page_exception(JavaThread *thread); 144 static void handle_polling_page_exception(JavaThread *thread);
141 145
142 // VM Thread interface for determining safepoint rate 146 // VM Thread interface for determining safepoint rate
143 static long last_non_safepoint_interval() { return os::javaTimeMillis() - _last_safepoint; } 147 static long last_non_safepoint_interval() {
148 return os::javaTimeMillis() - _end_of_last_safepoint;
149 }
144 static bool is_cleanup_needed(); 150 static bool is_cleanup_needed();
145 static void do_cleanup_tasks(); 151 static void do_cleanup_tasks();
146 152
147 // debugging 153 // debugging
148 static void print_state() PRODUCT_RETURN; 154 static void print_state() PRODUCT_RETURN;