author | mgronlun |
Mon, 02 Sep 2019 19:42:46 +0200 | |
branch | JEP-349-branch |
changeset 57983 | a57907813a83 |
parent 57887 | a9cc3698a55c |
child 58068 | 22dab580786c |
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/utilities/jfrTime.hpp" |
|
29 |
#include "jfr/utilities/jfrTypes.hpp" |
|
30 |
#include "runtime/mutexLocker.hpp" |
|
50117
fb66b2959eaf
8203251: Non-PCH build failed after JDK-8199712 (Flight Recorder)
shade
parents:
50113
diff
changeset
|
31 |
#include "runtime/os.inline.hpp" |
50113 | 32 |
|
57360 | 33 |
static const int64_t MAGIC_OFFSET = 0; |
34 |
static const int64_t MAGIC_LEN = 4; |
|
35 |
static const int64_t VERSION_OFFSET = MAGIC_LEN; |
|
36 |
static const int64_t SIZE_OFFSET = 8; |
|
37 |
static const int64_t SLOT_SIZE = 8; |
|
38 |
static const int64_t CHECKPOINT_OFFSET = SIZE_OFFSET + SLOT_SIZE; |
|
39 |
static const int64_t METADATA_OFFSET = CHECKPOINT_OFFSET + SLOT_SIZE; |
|
40 |
static const int64_t START_NANOS_OFFSET = METADATA_OFFSET + SLOT_SIZE; |
|
41 |
static const int64_t DURATION_NANOS_OFFSET = START_NANOS_OFFSET + SLOT_SIZE; |
|
42 |
static const int64_t START_TICKS_OFFSET = DURATION_NANOS_OFFSET + SLOT_SIZE; |
|
43 |
static const int64_t CPU_FREQUENCY_OFFSET = START_TICKS_OFFSET + SLOT_SIZE; |
|
44 |
static const int64_t GENERATION_OFFSET = CPU_FREQUENCY_OFFSET + SLOT_SIZE; |
|
45 |
static const int64_t CAPABILITY_OFFSET = GENERATION_OFFSET + 2; |
|
46 |
static const int64_t HEADER_SIZE = CAPABILITY_OFFSET + 2; |
|
50113 | 47 |
|
48 |
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
|
49 |
return path != NULL ? os::open(path, O_CREAT | O_RDWR, S_IREAD | S_IWRITE) : invalid_fd; |
50113 | 50 |
} |
51 |
||
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
|
52 |
#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
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
} |
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
|
57 |
#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
|
58 |
|
57360 | 59 |
class JfrChunkHeadWriter : public StackObj { |
60 |
private: |
|
61 |
JfrChunkWriter* _writer; |
|
62 |
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
|
63 |
public: |
57360 | 64 |
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
|
65 |
_writer->bytes(_chunk->magic(), MAGIC_LEN); |
57360 | 66 |
} |
67 |
||
68 |
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
|
69 |
_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
|
70 |
_writer->be_write(_chunk->minor_version()); |
57360 | 71 |
} |
72 |
||
73 |
void write_size(int64_t size) { |
|
74 |
_writer->be_write(size); |
|
75 |
} |
|
76 |
||
77 |
void write_checkpoint() { |
|
78 |
_writer->be_write(_chunk->last_checkpoint_offset()); |
|
79 |
} |
|
80 |
||
81 |
void write_metadata() { |
|
82 |
_writer->be_write(_chunk->last_metadata_offset()); |
|
83 |
} |
|
84 |
||
85 |
void write_time(bool finalize) { |
|
86 |
if (finalize) { |
|
87 |
_writer->be_write(_chunk->previous_start_nanos()); |
|
88 |
_writer->be_write(_chunk->last_chunk_duration()); |
|
89 |
_writer->be_write(_chunk->previous_start_ticks()); |
|
90 |
return; |
|
91 |
} |
|
92 |
_writer->be_write(_chunk->start_nanos()); |
|
93 |
_writer->be_write(_chunk->duration()); |
|
94 |
_writer->be_write(_chunk->start_ticks()); |
|
95 |
} |
|
96 |
||
97 |
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
|
98 |
_writer->be_write(_chunk->cpu_frequency()); |
57360 | 99 |
} |
100 |
||
101 |
void write_generation(bool finalize) { |
|
102 |
_writer->be_write(finalize ? COMPLETE : _chunk->generation()); |
|
103 |
_writer->be_write(PAD); |
|
104 |
} |
|
105 |
||
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
|
106 |
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
|
107 |
_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
|
108 |
_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
|
109 |
} |
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
|
110 |
|
57360 | 111 |
void write_guard() { |
112 |
_writer->be_write(GUARD); |
|
113 |
_writer->be_write(PAD); |
|
114 |
} |
|
115 |
||
116 |
void write_guard_flush() { |
|
117 |
write_guard(); |
|
118 |
_writer->flush(); |
|
50113 | 119 |
} |
57360 | 120 |
|
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
|
121 |
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
|
122 |
_writer->be_write(_chunk->capabilities()); |
57360 | 123 |
} |
124 |
||
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
|
125 |
void write_size_to_generation(int64_t size, bool finalize) { |
57360 | 126 |
write_size(size); |
127 |
write_checkpoint(); |
|
128 |
write_metadata(); |
|
129 |
write_time(finalize); |
|
130 |
write_cpu_frequency(); |
|
131 |
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
|
132 |
} |
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
|
133 |
|
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 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
|
135 |
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
|
136 |
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
|
137 |
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
|
138 |
write_size_to_generation(size, finalize); |
57360 | 139 |
// no need to write capabilities |
140 |
_writer->seek(size); // implicit flush |
|
141 |
} |
|
142 |
||
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
|
143 |
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
|
144 |
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
|
145 |
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
|
146 |
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
|
147 |
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
|
148 |
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
|
149 |
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
|
150 |
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
|
151 |
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
|
152 |
_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
|
153 |
} |
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
|
154 |
|
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
|
155 |
JfrChunkHeadWriter(JfrChunkWriter* writer, int64_t offset, bool head = true) : _writer(writer), _chunk(writer->_chunk) { |
57360 | 156 |
assert(_writer != NULL, "invariant"); |
157 |
assert(_writer->is_valid(), "invariant"); |
|
158 |
assert(_chunk != NULL, "invariant"); |
|
159 |
if (0 == _writer->current_offset()) { |
|
160 |
assert(HEADER_SIZE == offset, "invariant"); |
|
161 |
initialize(); |
|
162 |
} 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
|
163 |
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
|
164 |
_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
|
165 |
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
|
166 |
_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
|
167 |
} |
57360 | 168 |
} |
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
|
169 |
DEBUG_ONLY(assert_writer_position(_writer, offset);) |
57360 | 170 |
} |
171 |
}; |
|
172 |
||
57886
87f8a814310d
rename from JfrCheckpointMode to JfrCheckpointType
mgronlun
parents:
57882
diff
changeset
|
173 |
static void write_checkpoint_header(JfrChunkWriter& cw, int64_t event_offset, bool flushpoint) { |
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
|
174 |
const int64_t delta = cw.last_checkpoint_offset() == 0 ? 0 : cw.last_checkpoint_offset() - event_offset; |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57887
diff
changeset
|
175 |
const u4 checkpoint_type = flushpoint ? (u4)(FLUSH | HEADER) : (u4)HEADER; |
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 |
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
|
177 |
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
|
178 |
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
|
179 |
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
|
180 |
cw.write<u8>(delta); // to previous checkpoint |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57887
diff
changeset
|
181 |
cw.write<u4>(checkpoint_type); |
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 |
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
|
183 |
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
|
184 |
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
|
185 |
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
|
186 |
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
|
187 |
} |
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 |
|
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 |
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
|
190 |
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
|
191 |
const int64_t event_size_offset = current_offset(); |
57886
87f8a814310d
rename from JfrCheckpointMode to JfrCheckpointType
mgronlun
parents:
57882
diff
changeset
|
192 |
write_checkpoint_header(*this, event_size_offset, flushpoint); |
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
|
193 |
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
|
194 |
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
|
195 |
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
|
196 |
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
|
197 |
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
|
198 |
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
|
199 |
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
|
200 |
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
|
201 |
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
|
202 |
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
|
203 |
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
|
204 |
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
|
205 |
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
|
206 |
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
|
207 |
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
|
208 |
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
|
209 |
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
|
210 |
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
|
211 |
} |
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 |
|
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 |
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
|
214 |
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
|
215 |
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
|
216 |
_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
|
217 |
} |
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 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
|
219 |
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
|
220 |
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
|
221 |
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
|
222 |
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
|
223 |
} |
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 |
|
57360 | 225 |
JfrChunkWriter::JfrChunkWriter() : JfrChunkWriterBase(NULL), _chunk(new JfrChunk()) {} |
226 |
||
227 |
JfrChunkWriter::~JfrChunkWriter() { |
|
228 |
assert(_chunk != NULL, "invariant"); |
|
229 |
delete _chunk; |
|
50113 | 230 |
} |
231 |
||
57360 | 232 |
void JfrChunkWriter::set_path(const char* path) { |
233 |
assert(_chunk != NULL, "invariant"); |
|
234 |
_chunk->set_path(path); |
|
235 |
} |
|
236 |
||
57887 | 237 |
void JfrChunkWriter::set_time_stamp() { |
57360 | 238 |
assert(_chunk != NULL, "invariant"); |
57887 | 239 |
_chunk->set_time_stamp(); |
50113 | 240 |
} |
241 |
||
53897
0abec72a3ac2
8217647: JFR: recordings on 32-bit systems unreadable
bulasevich
parents:
50117
diff
changeset
|
242 |
int64_t JfrChunkWriter::size_written() const { |
50113 | 243 |
return this->is_valid() ? this->current_offset() : 0; |
244 |
} |
|
245 |
||
57360 | 246 |
int64_t JfrChunkWriter::last_checkpoint_offset() const { |
247 |
assert(_chunk != NULL, "invariant"); |
|
248 |
return _chunk->last_checkpoint_offset(); |
|
249 |
} |
|
250 |
||
251 |
int64_t JfrChunkWriter::current_chunk_start_nanos() const { |
|
252 |
assert(_chunk != NULL, "invariant"); |
|
253 |
return this->is_valid() ? _chunk->start_nanos() : invalid_time; |
|
254 |
} |
|
255 |
||
256 |
void JfrChunkWriter::set_last_checkpoint_offset(int64_t offset) { |
|
257 |
assert(_chunk != NULL, "invariant"); |
|
258 |
_chunk->set_last_checkpoint_offset(offset); |
|
259 |
} |
|
260 |
||
261 |
bool JfrChunkWriter::is_initial_flushpoint_for_chunk() const { |
|
262 |
assert(_chunk != NULL, "invariant"); |
|
263 |
assert(_chunk->is_started(), "invariant"); |
|
264 |
assert(!_chunk->is_finished(), "invariant"); |
|
265 |
return _chunk->is_initial_flush(); |
|
50113 | 266 |
} |
267 |
||
57360 | 268 |
void JfrChunkWriter::set_last_metadata_offset(int64_t offset) { |
269 |
assert(_chunk != NULL, "invariant"); |
|
270 |
_chunk->set_last_metadata_offset(offset); |
|
271 |
} |
|
272 |
||
273 |
bool JfrChunkWriter::has_metadata() const { |
|
274 |
assert(_chunk != NULL, "invariant"); |
|
275 |
return _chunk->has_metadata(); |
|
50113 | 276 |
} |
277 |
||
57360 | 278 |
bool JfrChunkWriter::open() { |
279 |
assert(_chunk != NULL, "invariant"); |
|
280 |
JfrChunkWriterBase::reset(open_chunk(_chunk->path())); |
|
281 |
const bool is_open = this->has_valid_fd(); |
|
282 |
if (is_open) { |
|
283 |
assert(0 == this->current_offset(), "invariant"); |
|
284 |
_chunk->reset(); |
|
285 |
JfrChunkHeadWriter head(this, HEADER_SIZE); |
|
286 |
} |
|
287 |
return is_open; |
|
50113 | 288 |
} |
57360 | 289 |
|
290 |
int64_t JfrChunkWriter::close() { |
|
291 |
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
|
292 |
const int64_t size_written = flushpoint(false); |
57360 | 293 |
this->close_fd(); |
294 |
assert(!this->is_valid(), "invariant"); |
|
295 |
return size_written; |
|
296 |
} |