# HG changeset patch # User mgronlun # Date 1568124177 -7200 # Node ID 76d4428af8b65bcf26ded3511e1f3c1838c9105b # Parent 22dab580786c4cc77b3f927284b2cff2b884adf4 flush chunk diff -r 22dab580786c -r 76d4428af8b6 src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp --- a/src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp Tue Sep 10 13:14:36 2019 +0200 +++ b/src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp Tue Sep 10 16:02:57 2019 +0200 @@ -120,7 +120,7 @@ _start_nanos = _last_update_nanos = nanos_now(); } -void JfrChunk::update() { +void JfrChunk::update_current_time() { _last_update_nanos = nanos_now(); } diff -r 22dab580786c -r 76d4428af8b6 src/hotspot/share/jfr/recorder/repository/jfrChunk.hpp --- a/src/hotspot/share/jfr/recorder/repository/jfrChunk.hpp Tue Sep 10 13:14:36 2019 +0200 +++ b/src/hotspot/share/jfr/recorder/repository/jfrChunk.hpp Tue Sep 10 16:02:57 2019 +0200 @@ -71,7 +71,7 @@ int64_t last_chunk_duration() const; void set_time_stamp(); - void update(); + void update_current_time(); void set_path(const char* path); const char* path() const; diff -r 22dab580786c -r 76d4428af8b6 src/hotspot/share/jfr/recorder/repository/jfrChunkWriter.cpp --- a/src/hotspot/share/jfr/recorder/repository/jfrChunkWriter.cpp Tue Sep 10 13:14:36 2019 +0200 +++ b/src/hotspot/share/jfr/recorder/repository/jfrChunkWriter.cpp Tue Sep 10 16:02:57 2019 +0200 @@ -152,7 +152,7 @@ _writer->flush(); } - JfrChunkHeadWriter(JfrChunkWriter* writer, int64_t offset, bool head = true) : _writer(writer), _chunk(writer->_chunk) { + JfrChunkHeadWriter(JfrChunkWriter* writer, int64_t offset, bool guard = true) : _writer(writer), _chunk(writer->_chunk) { assert(_writer != NULL, "invariant"); assert(_writer->is_valid(), "invariant"); assert(_chunk != NULL, "invariant"); @@ -160,7 +160,7 @@ assert(HEADER_SIZE == offset, "invariant"); initialize(); } else { - if (head) { + if (guard) { _writer->seek(GENERATION_OFFSET); write_guard(); _writer->seek(offset); @@ -170,7 +170,7 @@ } }; -static void write_checkpoint_header(JfrChunkWriter& cw, int64_t event_offset, bool flushpoint) { +static int64_t prepare_chunk_header_constant_pool(JfrChunkWriter& cw, int64_t event_offset, bool flushpoint) { const int64_t delta = cw.last_checkpoint_offset() == 0 ? 0 : cw.last_checkpoint_offset() - event_offset; const u4 checkpoint_type = flushpoint ? (u4)(FLUSH | HEADER) : (u4)HEADER; cw.reserve(sizeof(u4)); @@ -184,36 +184,36 @@ cw.write(1); // count cw.write(1); // key cw.write(HEADER_SIZE); // length of byte array + return cw.current_offset(); } int64_t JfrChunkWriter::write_chunk_header_checkpoint(bool flushpoint) { assert(this->has_valid_fd(), "invariant"); const int64_t event_size_offset = current_offset(); - write_checkpoint_header(*this, event_size_offset, flushpoint); - const int64_t start_offset = current_offset(); - JfrChunkHeadWriter head(this, start_offset, false); + const int64_t header_content_pos = prepare_chunk_header_constant_pool(*this, event_size_offset, flushpoint); + JfrChunkHeadWriter head(this, header_content_pos, false); head.write_magic(); head.write_version(); - const int64_t size_offset = reserve(sizeof(int64_t)); + const int64_t chunk_size_offset = reserve(sizeof(int64_t)); // size to be decided when we are done be_write(event_size_offset); // last checkpoint offset will be this checkpoint head.write_metadata(); head.write_time(false); head.write_cpu_frequency(); head.write_next_generation(); head.write_capabilities(); - assert(current_offset() - start_offset == HEADER_SIZE, "invariant"); + assert(current_offset() - header_content_pos == HEADER_SIZE, "invariant"); const u4 checkpoint_size = current_offset() - event_size_offset; write_padded_at_offset(checkpoint_size, event_size_offset); set_last_checkpoint_offset(event_size_offset); const size_t sz_written = size_written(); - write_be_at_offset(sz_written, size_offset); + write_be_at_offset(sz_written, chunk_size_offset); return sz_written; } -int64_t JfrChunkWriter::flushpoint(bool flushpoint) { +int64_t JfrChunkWriter::flush_chunk(bool flushpoint) { assert(_chunk != NULL, "invariant"); if (flushpoint) { - _chunk->update(); + _chunk->update_current_time(); } const int64_t sz_written = write_chunk_header_checkpoint(flushpoint); assert(size_written() == sz_written, "invariant"); @@ -282,7 +282,7 @@ int64_t JfrChunkWriter::close() { assert(this->has_valid_fd(), "invariant"); - const int64_t size_written = flushpoint(false); + const int64_t size_written = flush_chunk(false); this->close_fd(); assert(!this->is_valid(), "invariant"); return size_written; diff -r 22dab580786c -r 76d4428af8b6 src/hotspot/share/jfr/recorder/repository/jfrChunkWriter.hpp --- a/src/hotspot/share/jfr/recorder/repository/jfrChunkWriter.hpp Tue Sep 10 13:14:36 2019 +0200 +++ b/src/hotspot/share/jfr/recorder/repository/jfrChunkWriter.hpp Tue Sep 10 16:02:57 2019 +0200 @@ -42,7 +42,7 @@ private: JfrChunk* _chunk; void set_path(const char* path); - int64_t flushpoint(bool finalize); + int64_t flush_chunk(bool flushpoint); bool open(); int64_t close(); int64_t current_chunk_start_nanos() const; @@ -56,6 +56,7 @@ int64_t last_checkpoint_offset() const; void set_last_checkpoint_offset(int64_t offset); void set_last_metadata_offset(int64_t offset); + bool has_metadata() const; void set_time_stamp(); }; diff -r 22dab580786c -r 76d4428af8b6 src/hotspot/share/jfr/recorder/repository/jfrRepository.cpp --- a/src/hotspot/share/jfr/recorder/repository/jfrRepository.cpp Tue Sep 10 13:14:36 2019 +0200 +++ b/src/hotspot/share/jfr/recorder/repository/jfrRepository.cpp Tue Sep 10 16:02:57 2019 +0200 @@ -175,5 +175,5 @@ } size_t JfrRepository::flush_chunk() { - return _chunkwriter->flushpoint(true); + return _chunkwriter->flush_chunk(true); }