author | mgronlun |
Mon, 26 Aug 2019 17:59:32 +0200 | |
branch | JEP-349-branch |
changeset 57882 | 562f598d303c |
parent 57870 | 00860d9caf4d |
child 57886 | 87f8a814310d |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
54263
3cabb47758c9
8217362: Emergency dump does not work when disk=false is set
mgronlun
parents:
53897
diff
changeset
|
2 |
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
50113 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#include "precompiled.hpp" |
|
57360 | 26 |
#include "jfr/recorder/repository/jfrChunk.hpp" |
50113 | 27 |
#include "jfr/recorder/repository/jfrChunkWriter.hpp" |
28 |
#include "jfr/recorder/service/jfrOptionSet.hpp" |
|
29 |
#include "jfr/utilities/jfrTime.hpp" |
|
57360 | 30 |
#include "jfr/utilities/jfrTimeConverter.hpp" |
50113 | 31 |
#include "jfr/utilities/jfrTypes.hpp" |
32 |
#include "runtime/mutexLocker.hpp" |
|
33 |
#include "runtime/os.hpp" |
|
50117
fb66b2959eaf
8203251: Non-PCH build failed after JDK-8199712 (Flight Recorder)
shade
parents:
50113
diff
changeset
|
34 |
#include "runtime/os.inline.hpp" |
50113 | 35 |
|
57360 | 36 |
static const int64_t MAGIC_OFFSET = 0; |
37 |
static const int64_t MAGIC_LEN = 4; |
|
38 |
static const int64_t VERSION_OFFSET = MAGIC_LEN; |
|
39 |
static const int64_t SIZE_OFFSET = 8; |
|
40 |
static const int64_t SLOT_SIZE = 8; |
|
41 |
static const int64_t CHECKPOINT_OFFSET = SIZE_OFFSET + SLOT_SIZE; |
|
42 |
static const int64_t METADATA_OFFSET = CHECKPOINT_OFFSET + SLOT_SIZE; |
|
43 |
static const int64_t START_NANOS_OFFSET = METADATA_OFFSET + SLOT_SIZE; |
|
44 |
static const int64_t DURATION_NANOS_OFFSET = START_NANOS_OFFSET + SLOT_SIZE; |
|
45 |
static const int64_t START_TICKS_OFFSET = DURATION_NANOS_OFFSET + SLOT_SIZE; |
|
46 |
static const int64_t CPU_FREQUENCY_OFFSET = START_TICKS_OFFSET + SLOT_SIZE; |
|
47 |
static const int64_t GENERATION_OFFSET = CPU_FREQUENCY_OFFSET + SLOT_SIZE; |
|
48 |
static const int64_t CAPABILITY_OFFSET = GENERATION_OFFSET + 2; |
|
49 |
static const int64_t HEADER_SIZE = CAPABILITY_OFFSET + 2; |
|
50 |
static const int64_t RESERVE_SIZE = GENERATION_OFFSET - (4 * SIZE_OFFSET); |
|
51 |
||
52 |
static const u1 COMPLETE = 0; |
|
53 |
static const u1 GUARD = 0xff; |
|
54 |
static const u1 PAD = 0; |
|
55 |
||
56 |
typedef NoOwnershipAdapter JfrHeadBuffer; // stack local array as buffer |
|
57 |
typedef StreamWriterHost<JfrHeadBuffer, StackObj> JfrBufferedHeadWriter; |
|
58 |
typedef WriterHost<BigEndianEncoder, BigEndianEncoder, JfrBufferedHeadWriter> JfrHeadWriterBase; |
|
59 |
||
50113 | 60 |
|
61 |
static fio_fd open_chunk(const char* path) { |
|
54263
3cabb47758c9
8217362: Emergency dump does not work when disk=false is set
mgronlun
parents:
53897
diff
changeset
|
62 |
return path != NULL ? os::open(path, O_CREAT | O_RDWR, S_IREAD | S_IWRITE) : invalid_fd; |
50113 | 63 |
} |
64 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
65 |
#ifdef ASSERT |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
66 |
static void assert_writer_position(JfrChunkWriter* writer, int64_t offset) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
67 |
assert(writer != NULL, "invariant"); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
68 |
assert(offset == writer->current_offset(), "invariant"); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
69 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
70 |
#endif |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
71 |
|
57360 | 72 |
class JfrChunkHeadWriter : public StackObj { |
73 |
private: |
|
74 |
JfrChunkWriter* _writer; |
|
75 |
JfrChunk* _chunk; |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
76 |
public: |
57360 | 77 |
void write_magic() { |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
78 |
_writer->bytes(_chunk->magic(), MAGIC_LEN); |
57360 | 79 |
} |
80 |
||
81 |
void write_version() { |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
82 |
_writer->be_write(_chunk->major_version()); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
83 |
_writer->be_write(_chunk->minor_version()); |
57360 | 84 |
} |
85 |
||
86 |
void write_size(int64_t size) { |
|
87 |
_writer->be_write(size); |
|
88 |
} |
|
89 |
||
90 |
void write_checkpoint() { |
|
91 |
_writer->be_write(_chunk->last_checkpoint_offset()); |
|
92 |
} |
|
93 |
||
94 |
void write_metadata() { |
|
95 |
_writer->be_write(_chunk->last_metadata_offset()); |
|
96 |
} |
|
97 |
||
98 |
void write_time(bool finalize) { |
|
99 |
if (finalize) { |
|
100 |
_writer->be_write(_chunk->previous_start_nanos()); |
|
101 |
_writer->be_write(_chunk->last_chunk_duration()); |
|
102 |
_writer->be_write(_chunk->previous_start_ticks()); |
|
103 |
return; |
|
104 |
} |
|
105 |
_writer->be_write(_chunk->start_nanos()); |
|
106 |
_writer->be_write(_chunk->duration()); |
|
107 |
_writer->be_write(_chunk->start_ticks()); |
|
108 |
} |
|
109 |
||
110 |
void write_cpu_frequency() { |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
111 |
_writer->be_write(_chunk->cpu_frequency()); |
57360 | 112 |
} |
113 |
||
114 |
void write_generation(bool finalize) { |
|
115 |
_writer->be_write(finalize ? COMPLETE : _chunk->generation()); |
|
116 |
_writer->be_write(PAD); |
|
117 |
} |
|
118 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
119 |
void write_next_generation() { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
120 |
_writer->be_write(_chunk->next_generation()); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
121 |
_writer->be_write(PAD); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
122 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
123 |
|
57360 | 124 |
void write_guard() { |
125 |
_writer->be_write(GUARD); |
|
126 |
_writer->be_write(PAD); |
|
127 |
} |
|
128 |
||
129 |
void write_guard_flush() { |
|
130 |
write_guard(); |
|
131 |
_writer->flush(); |
|
50113 | 132 |
} |
57360 | 133 |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
134 |
void write_capabilities() { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
135 |
_writer->be_write(_chunk->capabilities()); |
57360 | 136 |
} |
137 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
138 |
void write_size_to_generation(int64_t size, bool finalize) { |
57360 | 139 |
write_size(size); |
140 |
write_checkpoint(); |
|
141 |
write_metadata(); |
|
142 |
write_time(finalize); |
|
143 |
write_cpu_frequency(); |
|
144 |
write_generation(finalize); |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
145 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
146 |
|
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
147 |
void flush(int64_t size, bool finalize) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
148 |
assert(_writer->is_valid(), "invariant"); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
149 |
assert(_chunk != NULL, "invariant"); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
150 |
DEBUG_ONLY(assert_writer_position(_writer, SIZE_OFFSET);) |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
151 |
write_size_to_generation(size, finalize); |
57360 | 152 |
// no need to write capabilities |
153 |
_writer->seek(size); // implicit flush |
|
154 |
} |
|
155 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
156 |
void initialize() { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
157 |
assert(_writer->is_valid(), "invariant"); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
158 |
assert(_chunk != NULL, "invariant"); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
159 |
DEBUG_ONLY(assert_writer_position(_writer, 0);) |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
160 |
write_magic(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
161 |
write_version(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
162 |
write_size_to_generation(HEADER_SIZE, false); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
163 |
write_capabilities(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
164 |
DEBUG_ONLY(assert_writer_position(_writer, HEADER_SIZE);) |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
165 |
_writer->flush(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
166 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
167 |
|
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
168 |
JfrChunkHeadWriter(JfrChunkWriter* writer, int64_t offset, bool head = true) : _writer(writer), _chunk(writer->_chunk) { |
57360 | 169 |
assert(_writer != NULL, "invariant"); |
170 |
assert(_writer->is_valid(), "invariant"); |
|
171 |
assert(_chunk != NULL, "invariant"); |
|
172 |
if (0 == _writer->current_offset()) { |
|
173 |
assert(HEADER_SIZE == offset, "invariant"); |
|
174 |
initialize(); |
|
175 |
} else { |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
176 |
if (head) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
177 |
_writer->seek(GENERATION_OFFSET); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
178 |
write_guard(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
179 |
_writer->seek(offset); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
180 |
} |
57360 | 181 |
} |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
182 |
DEBUG_ONLY(assert_writer_position(_writer, offset);) |
57360 | 183 |
} |
184 |
}; |
|
185 |
||
57882 | 186 |
static void write_checkpoint_header(JfrChunkWriter& cw, int64_t event_offset, u1 mode) { |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
187 |
const int64_t delta = cw.last_checkpoint_offset() == 0 ? 0 : cw.last_checkpoint_offset() - event_offset; |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
188 |
cw.reserve(sizeof(u4)); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
189 |
cw.write<u8>(EVENT_CHECKPOINT); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
190 |
cw.write<u8>(JfrTicks::now().value()); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
191 |
cw.write<u8>(0); // duration |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
192 |
cw.write<u8>(delta); // to previous checkpoint |
57882 | 193 |
cw.write<u1>(mode); |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
194 |
cw.write<u4>(1); // pool count |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
195 |
cw.write<u8>(TYPE_CHUNKHEADER); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
196 |
cw.write<u4>(1); // count |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
197 |
cw.write<u8>(1); // key |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
198 |
cw.write<u4>(HEADER_SIZE); // length of byte array |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
199 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
200 |
|
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
201 |
int64_t JfrChunkWriter::write_chunk_header_checkpoint(bool flushpoint) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
202 |
assert(this->has_valid_fd(), "invariant"); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
203 |
const int64_t event_size_offset = current_offset(); |
57882 | 204 |
const u1 mode = flushpoint ? FLUSH | HEADER : HEADER; |
205 |
write_checkpoint_header(*this, event_size_offset, mode); |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
206 |
const int64_t start_offset = current_offset(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
207 |
JfrChunkHeadWriter head(this, start_offset, false); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
208 |
head.write_magic(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
209 |
head.write_version(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
210 |
const int64_t size_offset = reserve(sizeof(int64_t)); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
211 |
be_write(event_size_offset); // last checkpoint offset will be this checkpoint |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
212 |
head.write_metadata(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
213 |
head.write_time(false); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
214 |
head.write_cpu_frequency(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
215 |
head.write_next_generation(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
216 |
head.write_capabilities(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
217 |
assert(current_offset() - start_offset == HEADER_SIZE, "invariant"); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
218 |
const u4 checkpoint_size = current_offset() - event_size_offset; |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
219 |
write_padded_at_offset<u4>(checkpoint_size, event_size_offset); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
220 |
set_last_checkpoint_offset(event_size_offset); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
221 |
const size_t sz_written = size_written(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
222 |
write_be_at_offset(sz_written, size_offset); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
223 |
return sz_written; |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
224 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
225 |
|
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
226 |
int64_t JfrChunkWriter::flushpoint(bool flushpoint) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
227 |
assert(_chunk != NULL, "invariant"); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
228 |
if (flushpoint) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
229 |
_chunk->update(); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
230 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
231 |
const int64_t sz_written = write_chunk_header_checkpoint(flushpoint); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
232 |
assert(size_written() == sz_written, "invariant"); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
233 |
JfrChunkHeadWriter head(this, SIZE_OFFSET); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
234 |
head.flush(sz_written, !flushpoint); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
235 |
return sz_written; |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
236 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
237 |
|
57360 | 238 |
JfrChunkWriter::JfrChunkWriter() : JfrChunkWriterBase(NULL), _chunk(new JfrChunk()) {} |
239 |
||
240 |
JfrChunkWriter::~JfrChunkWriter() { |
|
241 |
assert(_chunk != NULL, "invariant"); |
|
242 |
delete _chunk; |
|
50113 | 243 |
} |
244 |
||
57360 | 245 |
void JfrChunkWriter::set_path(const char* path) { |
246 |
assert(_chunk != NULL, "invariant"); |
|
247 |
_chunk->set_path(path); |
|
248 |
} |
|
249 |
||
250 |
void JfrChunkWriter::time_stamp_chunk_now() { |
|
251 |
assert(_chunk != NULL, "invariant"); |
|
252 |
_chunk->update_time_to_now(); |
|
50113 | 253 |
} |
254 |
||
53897
0abec72a3ac2
8217647: JFR: recordings on 32-bit systems unreadable
bulasevich
parents:
50117
diff
changeset
|
255 |
int64_t JfrChunkWriter::size_written() const { |
50113 | 256 |
return this->is_valid() ? this->current_offset() : 0; |
257 |
} |
|
258 |
||
57360 | 259 |
int64_t JfrChunkWriter::last_checkpoint_offset() const { |
260 |
assert(_chunk != NULL, "invariant"); |
|
261 |
return _chunk->last_checkpoint_offset(); |
|
262 |
} |
|
263 |
||
264 |
int64_t JfrChunkWriter::current_chunk_start_nanos() const { |
|
265 |
assert(_chunk != NULL, "invariant"); |
|
266 |
return this->is_valid() ? _chunk->start_nanos() : invalid_time; |
|
267 |
} |
|
268 |
||
269 |
void JfrChunkWriter::set_last_checkpoint_offset(int64_t offset) { |
|
270 |
assert(_chunk != NULL, "invariant"); |
|
271 |
_chunk->set_last_checkpoint_offset(offset); |
|
272 |
} |
|
273 |
||
274 |
bool JfrChunkWriter::is_initial_flushpoint_for_chunk() const { |
|
275 |
assert(_chunk != NULL, "invariant"); |
|
276 |
assert(_chunk->is_started(), "invariant"); |
|
277 |
assert(!_chunk->is_finished(), "invariant"); |
|
278 |
return _chunk->is_initial_flush(); |
|
50113 | 279 |
} |
280 |
||
57360 | 281 |
void JfrChunkWriter::set_last_metadata_offset(int64_t offset) { |
282 |
assert(_chunk != NULL, "invariant"); |
|
283 |
_chunk->set_last_metadata_offset(offset); |
|
284 |
} |
|
285 |
||
286 |
bool JfrChunkWriter::has_metadata() const { |
|
287 |
assert(_chunk != NULL, "invariant"); |
|
288 |
return _chunk->has_metadata(); |
|
50113 | 289 |
} |
290 |
||
57360 | 291 |
bool JfrChunkWriter::open() { |
292 |
assert(_chunk != NULL, "invariant"); |
|
293 |
JfrChunkWriterBase::reset(open_chunk(_chunk->path())); |
|
294 |
const bool is_open = this->has_valid_fd(); |
|
295 |
if (is_open) { |
|
296 |
assert(0 == this->current_offset(), "invariant"); |
|
297 |
_chunk->reset(); |
|
298 |
JfrChunkHeadWriter head(this, HEADER_SIZE); |
|
299 |
} |
|
300 |
return is_open; |
|
50113 | 301 |
} |
57360 | 302 |
|
303 |
int64_t JfrChunkWriter::close() { |
|
304 |
assert(this->has_valid_fd(), "invariant"); |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
305 |
const int64_t size_written = flushpoint(false); |
57360 | 306 |
this->close_fd(); |
307 |
assert(!this->is_valid(), "invariant"); |
|
308 |
return size_written; |
|
309 |
} |