Print this page
rev 2869 : 7117303: VM uses non-monotonic time source and complains that it is non-monotonic
Summary: Replaces calls to os::javaTimeMillis(), which does not guarantee montonicity, in GC code to os::javaTimeNanos() with a suitable conversion factor. os::javaTimeNanos() mostly guarantees montonicity depending on the underlying OS implementation and, as a result, a better alternative. Changes in OS files are to make use of the newly defined constants in globalDefinitions.hpp.
Reviewed-by:

Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
          +++ new/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
↓ open down ↓ 3390 lines elided ↑ open up ↑
3391 3391  
3392 3392      ParMarkBitMap::IterationStatus status;
3393 3393      status = bitmap->iterate(&closure, dest_addr, end_addr);
3394 3394      assert(status == ParMarkBitMap::full, "iteration not complete");
3395 3395      assert(bitmap->find_obj_beg(closure.source(), end_addr) == end_addr,
3396 3396             "live objects skipped because closure is full");
3397 3397    }
3398 3398  }
3399 3399  
3400 3400  jlong PSParallelCompact::millis_since_last_gc() {
3401      -  jlong ret_val = os::javaTimeMillis() - _time_of_last_gc;
     3401 +  // os::javaTimeMillis() does not guarantee monotonicity.
     3402 +  jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
     3403 +  jlong ret_val = now - _time_of_last_gc;
3402 3404    // XXX See note in genCollectedHeap::millis_since_last_gc().
3403 3405    if (ret_val < 0) {
3404      -    NOT_PRODUCT(warning("time warp: %d", ret_val);)
     3406 +    NOT_PRODUCT(warning("time warp: "INT64_FORMAT, ret_val);)
3405 3407      return 0;
3406 3408    }
3407 3409    return ret_val;
3408 3410  }
3409 3411  
3410 3412  void PSParallelCompact::reset_millis_since_last_gc() {
3411      -  _time_of_last_gc = os::javaTimeMillis();
     3413 +  // os::javaTimeMillis() does not guarantee monotonicity.
     3414 +  _time_of_last_gc = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
3412 3415  }
3413 3416  
3414 3417  ParMarkBitMap::IterationStatus MoveAndUpdateClosure::copy_until_full()
3415 3418  {
3416 3419    if (source() != destination()) {
3417 3420      DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
3418 3421      Copy::aligned_conjoint_words(source(), destination(), words_remaining());
3419 3422    }
3420 3423    update_state(words_remaining());
3421 3424    assert(is_full(), "sanity");
↓ open down ↓ 79 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX