stricly monotone nanos for chunkheader JEP-349-branch
authormgronlun
Wed, 30 Oct 2019 11:28:38 +0100
branchJEP-349-branch
changeset 58854 a79e68ec829a
parent 58853 4c036608ca8b
child 58855 83c307e00630
stricly monotone nanos for chunkheader
src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp
src/hotspot/share/jfr/recorder/service/jfrPostBox.hpp
--- a/src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp	Wed Oct 30 11:23:55 2019 +0100
+++ b/src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp	Wed Oct 30 11:28:38 2019 +0100
@@ -32,10 +32,18 @@
 
 static const char* const MAGIC = "FLR";
 static const u2 JFR_VERSION_MAJOR = 2;
-static const u2 JFR_VERSION_MINOR = 0;
+static const u2 JFR_VERSION_MINOR = 1;
 
+// strictly monotone
 static jlong nanos_now() {
-  return os::javaTimeMillis() * JfrTimeConverter::NANOS_PER_MILLISEC;
+  static jlong last = 0;
+  const jlong now = os::javaTimeMillis() * JfrTimeConverter::NANOS_PER_MILLISEC;
+  if (now > last) {
+    last = now;
+  } else {
+    ++last;
+  }
+  return last;
 }
 
 static jlong ticks_now() {
@@ -122,11 +130,16 @@
 }
 
 void JfrChunk::update_start_nanos() {
-  _start_nanos = _last_update_nanos = nanos_now();
+  const jlong now = nanos_now();
+  assert(now > _start_nanos, "invariant");
+  assert(now > _last_update_nanos, "invariant");
+  _start_nanos = _last_update_nanos = now;
 }
 
 void JfrChunk::update_current_nanos() {
-  _last_update_nanos = nanos_now();
+  const jlong now = nanos_now();
+  assert(now > _last_update_nanos, "invariant");
+  _last_update_nanos = now;
 }
 
 void JfrChunk::save_current_and_update_start_ticks() {
--- a/src/hotspot/share/jfr/recorder/service/jfrPostBox.hpp	Wed Oct 30 11:23:55 2019 +0100
+++ b/src/hotspot/share/jfr/recorder/service/jfrPostBox.hpp	Wed Oct 30 11:28:38 2019 +0100
@@ -42,7 +42,6 @@
   MSG_VM_ERROR,
   MSG_DEADBUFFER,
   MSG_FLUSHPOINT,
-  MSG_FLUSHPOINT_METADATA,
   MSG_NO_OF_MSGS
 };
 
@@ -55,15 +54,16 @@
  *  MSG_START(1)            ; MSGBIT(MSG_START) == (1 << 0x1) == 0x2
  *  MSG_STOP (2)            ; MSGBIT(MSG_STOP) == (1 << 0x2) == 0x4
  *  MSG_ROTATE (3)          ; MSGBIT(MSG_ROTATE) == (1 << 0x3) == 0x8
- *  MSG_VM_ERROR (8)        ; MSGBIT(MSG_VM_ERROR) == (1 << 8) == 0x100
+ *  MSG_VM_ERROR (8)        ; MSGBIT(MSG_VM_ERROR) == (1 << 0x8) == 0x100
+ *  MSG_FLUSHPOINT (10)     ; MSGBIT(MSG_FLUSHPOINT) == (1 << 0xa) == 0x400
  *
  *  Asynchronous messages (posting thread returns immediately upon deposit):
  *
  *  MSG_FULLBUFFER (4)      ; MSGBIT(MSG_FULLBUFFER) == (1 << 0x4) == 0x10
- *  MSG_CHECKPOINT (5)      ; MSGBIT(CHECKPOINT) == (1 << 5) == 0x20
- *  MSG_WAKEUP (6)          ; MSGBIT(WAKEUP) == (1 << 6) == 0x40
- *  MSG_SHUTDOWN (7)        ; MSGBIT(MSG_SHUTDOWN) == (1 << 7) == 0x80
- *  MSG_DEADBUFFER (9)      ; MSGBIT(MSG_DEADBUFFER) == (1 << 9) == 0x200
+ *  MSG_CHECKPOINT (5)      ; MSGBIT(CHECKPOINT) == (1 << 0x5) == 0x20
+ *  MSG_WAKEUP (6)          ; MSGBIT(WAKEUP) == (1 << 0x6) == 0x40
+ *  MSG_SHUTDOWN (7)        ; MSGBIT(MSG_SHUTDOWN) == (1 << 0x7) == 0x80
+ *  MSG_DEADBUFFER (9)      ; MSGBIT(MSG_DEADBUFFER) == (1 << 0x9) == 0x200
  */
 
 class JfrPostBox : public JfrCHeapObj {