339 //
340 // The durations measure: end_time[n] - start_time[n]
341 // The periods measure: start_time[n] - start_time[n-1]
342 //
343 // The cms period and duration include only concurrent collections; time spent
344 // in foreground cms collections due to System.gc() or because of a failure to
345 // keep up are not included.
346 //
347 // There are 3 alphas to "bootstrap" the statistics. The _saved_alpha is the
348 // real value, but is used only after the first period. A value of 100 is
349 // used for the first sample so it gets the entire weight.
350 unsigned int _saved_alpha; // 0-100
351 unsigned int _gc0_alpha;
352 unsigned int _cms_alpha;
353
354 double _gc0_duration;
355 double _gc0_period;
356 size_t _gc0_promoted; // bytes promoted per gc0
357 double _cms_duration;
358 double _cms_duration_pre_sweep; // time from initiation to start of sweep
359 double _cms_duration_per_mb;
360 double _cms_period;
361 size_t _cms_allocated; // bytes of direct allocation per gc0 period
362
363 // Timers.
364 elapsedTimer _cms_timer;
365 TimeStamp _gc0_begin_time;
366 TimeStamp _cms_begin_time;
367 TimeStamp _cms_end_time;
368
369 // Snapshots of the amount used in the CMS generation.
370 size_t _cms_used_at_gc0_begin;
371 size_t _cms_used_at_gc0_end;
372 size_t _cms_used_at_cms_begin;
373
374 // Used to prevent the duty cycle from being reduced in the middle of a cms
375 // cycle.
376 bool _allow_duty_cycle_reduction;
377
378 enum {
379 _GC0_VALID = 0x1,
399 bool valid() const;
400
401 // Record statistics.
402 void record_gc0_begin();
403 void record_gc0_end(size_t cms_gen_bytes_used);
404 void record_cms_begin();
405 void record_cms_end();
406
407 // Allow management of the cms timer, which must be stopped/started around
408 // yield points.
409 elapsedTimer& cms_timer() { return _cms_timer; }
410 void start_cms_timer() { _cms_timer.start(); }
411 void stop_cms_timer() { _cms_timer.stop(); }
412
413 // Basic statistics; units are seconds or bytes.
414 double gc0_period() const { return _gc0_period; }
415 double gc0_duration() const { return _gc0_duration; }
416 size_t gc0_promoted() const { return _gc0_promoted; }
417 double cms_period() const { return _cms_period; }
418 double cms_duration() const { return _cms_duration; }
419 double cms_duration_per_mb() const { return _cms_duration_per_mb; }
420 size_t cms_allocated() const { return _cms_allocated; }
421
422 size_t cms_used_at_gc0_end() const { return _cms_used_at_gc0_end;}
423
424 // Seconds since the last background cms cycle began or ended.
425 double cms_time_since_begin() const;
426 double cms_time_since_end() const;
427
428 // Higher level statistics--caller must check that valid() returns true before
429 // calling.
430
431 // Returns bytes promoted per second of wall clock time.
432 double promotion_rate() const;
433
434 // Returns bytes directly allocated per second of wall clock time.
435 double cms_allocation_rate() const;
436
437 // Rate at which space in the cms generation is being consumed (sum of the
438 // above two).
439 double cms_consumption_rate() const;
|
339 //
340 // The durations measure: end_time[n] - start_time[n]
341 // The periods measure: start_time[n] - start_time[n-1]
342 //
343 // The cms period and duration include only concurrent collections; time spent
344 // in foreground cms collections due to System.gc() or because of a failure to
345 // keep up are not included.
346 //
347 // There are 3 alphas to "bootstrap" the statistics. The _saved_alpha is the
348 // real value, but is used only after the first period. A value of 100 is
349 // used for the first sample so it gets the entire weight.
350 unsigned int _saved_alpha; // 0-100
351 unsigned int _gc0_alpha;
352 unsigned int _cms_alpha;
353
354 double _gc0_duration;
355 double _gc0_period;
356 size_t _gc0_promoted; // bytes promoted per gc0
357 double _cms_duration;
358 double _cms_duration_pre_sweep; // time from initiation to start of sweep
359 double _cms_period;
360 size_t _cms_allocated; // bytes of direct allocation per gc0 period
361
362 // Timers.
363 elapsedTimer _cms_timer;
364 TimeStamp _gc0_begin_time;
365 TimeStamp _cms_begin_time;
366 TimeStamp _cms_end_time;
367
368 // Snapshots of the amount used in the CMS generation.
369 size_t _cms_used_at_gc0_begin;
370 size_t _cms_used_at_gc0_end;
371 size_t _cms_used_at_cms_begin;
372
373 // Used to prevent the duty cycle from being reduced in the middle of a cms
374 // cycle.
375 bool _allow_duty_cycle_reduction;
376
377 enum {
378 _GC0_VALID = 0x1,
398 bool valid() const;
399
400 // Record statistics.
401 void record_gc0_begin();
402 void record_gc0_end(size_t cms_gen_bytes_used);
403 void record_cms_begin();
404 void record_cms_end();
405
406 // Allow management of the cms timer, which must be stopped/started around
407 // yield points.
408 elapsedTimer& cms_timer() { return _cms_timer; }
409 void start_cms_timer() { _cms_timer.start(); }
410 void stop_cms_timer() { _cms_timer.stop(); }
411
412 // Basic statistics; units are seconds or bytes.
413 double gc0_period() const { return _gc0_period; }
414 double gc0_duration() const { return _gc0_duration; }
415 size_t gc0_promoted() const { return _gc0_promoted; }
416 double cms_period() const { return _cms_period; }
417 double cms_duration() const { return _cms_duration; }
418 size_t cms_allocated() const { return _cms_allocated; }
419
420 size_t cms_used_at_gc0_end() const { return _cms_used_at_gc0_end;}
421
422 // Seconds since the last background cms cycle began or ended.
423 double cms_time_since_begin() const;
424 double cms_time_since_end() const;
425
426 // Higher level statistics--caller must check that valid() returns true before
427 // calling.
428
429 // Returns bytes promoted per second of wall clock time.
430 double promotion_rate() const;
431
432 // Returns bytes directly allocated per second of wall clock time.
433 double cms_allocation_rate() const;
434
435 // Rate at which space in the cms generation is being consumed (sum of the
436 // above two).
437 double cms_consumption_rate() const;
|