Skip to content

Commit ae97809

Browse files
koarzdataroaring
authored andcommitted
fix
1 parent 6a85f3a commit ae97809

File tree

7 files changed

+41
-10
lines changed

7 files changed

+41
-10
lines changed

be/src/cloud/cloud_base_compaction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ Status CloudBaseCompaction::execute_compact() {
303303
.tag("output_rowset_data_size", _output_rowset->data_disk_size())
304304
.tag("output_rowset_index_size", _output_rowset->index_disk_size())
305305
.tag("output_rowset_total_size", _output_rowset->total_disk_size())
306-
.tag("local_read_time_ns", _stats.cloud_local_read_time)
307-
.tag("remote_read_time_ns", _stats.cloud_remote_read_time);
306+
.tag("local_read_time_ms", _stats.cloud_local_read_time)
307+
.tag("remote_read_time_ms", _stats.cloud_remote_read_time);
308308

309309
//_compaction_succeed = true;
310310
_state = CompactionState::SUCCESS;

be/src/cloud/cloud_cumulative_compaction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ Status CloudCumulativeCompaction::execute_compact() {
227227
.tag("cumulative_point", cloud_tablet()->cumulative_layer_point())
228228
.tag("num_rowsets", cloud_tablet()->fetch_add_approximate_num_rowsets(0))
229229
.tag("cumu_num_rowsets", cloud_tablet()->fetch_add_approximate_cumu_num_rowsets(0))
230-
.tag("local_read_time_ns", _stats.cloud_local_read_time)
231-
.tag("remote_read_time_ns", _stats.cloud_remote_read_time);
230+
.tag("local_read_time_ms", _stats.cloud_local_read_time)
231+
.tag("remote_read_time_ms", _stats.cloud_remote_read_time);
232232

233233
_state = CompactionState::SUCCESS;
234234

be/src/cloud/cloud_full_compaction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ Status CloudFullCompaction::execute_compact() {
183183
.tag("output_rowset_data_size", _output_rowset->data_disk_size())
184184
.tag("output_rowset_index_size", _output_rowset->index_disk_size())
185185
.tag("output_rowset_total_size", _output_rowset->total_disk_size())
186-
.tag("local_read_time_ns", _stats.cloud_local_read_time)
187-
.tag("remote_read_time_ns", _stats.cloud_remote_read_time);
186+
.tag("local_read_time_ms", _stats.cloud_local_read_time)
187+
.tag("remote_read_time_ms", _stats.cloud_remote_read_time);
188188

189189
_state = CompactionState::SUCCESS;
190190

be/src/cloud/cloud_tablet.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "cloud/cloud_tablet.h"
1919

20+
#include <gen_cpp/Types_types.h>
2021
#include <gen_cpp/olap_file.pb.h>
2122
#include <rapidjson/document.h>
2223
#include <rapidjson/encodings.h>
@@ -733,6 +734,21 @@ void CloudTablet::get_compaction_status(std::string* json_result) {
733734
cast_set<uint>(_last_full_compaction_status.length()),
734735
root.GetAllocator());
735736
root.AddMember("last full status", full_compaction_status_value, root.GetAllocator());
737+
rapidjson::Value exec_compaction_time;
738+
std::string num_str {std::to_string(exec_compaction_time_ms.load())};
739+
full_schedule_value.SetString(num_str.c_str(), cast_set<uint>(num_str.length()),
740+
root.GetAllocator());
741+
root.AddMember("exec compaction time ms", full_schedule_value, root.GetAllocator());
742+
rapidjson::Value local_read_time;
743+
num_str = std::to_string(local_read_time_ms.load());
744+
full_schedule_value.SetString(num_str.c_str(), cast_set<uint>(num_str.length()),
745+
root.GetAllocator());
746+
root.AddMember("compaction local read time ms", full_schedule_value, root.GetAllocator());
747+
rapidjson::Value remote_read_time;
748+
num_str = std::to_string(remote_read_time_ms.load());
749+
full_schedule_value.SetString(num_str.c_str(), cast_set<uint>(num_str.length()),
750+
root.GetAllocator());
751+
root.AddMember("compaction remote read time ms", full_schedule_value, root.GetAllocator());
736752

737753
// print all rowsets' version as an array
738754
rapidjson::Document versions_arr;

be/src/cloud/cloud_tablet.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ class CloudTablet final : public BaseTablet {
260260
int64_t last_cumu_no_suitable_version_ms = 0;
261261
int64_t last_access_time_ms = 0;
262262

263+
std::atomic<int64_t> local_read_time_ms = 0;
264+
std::atomic<int64_t> remote_read_time_ms = 0;
265+
std::atomic<int64_t> exec_compaction_time_ms = 0;
266+
263267
// Return merged extended schema
264268
TabletSchemaSPtr merged_tablet_schema() const override;
265269

be/src/olap/compaction.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
#include "cloud/cloud_meta_mgr.h"
4040
#include "cloud/cloud_storage_engine.h"
41+
#include "cloud/cloud_tablet.h"
4142
#include "common/config.h"
4243
#include "common/status.h"
4344
#include "cpp/sync_point.h"
@@ -1468,6 +1469,12 @@ Status CloudCompactionMixin::execute_compact_impl(int64_t permits) {
14681469
// 4. modify rowsets in memory
14691470
RETURN_IF_ERROR(modify_rowsets());
14701471

1472+
// update compaction status data
1473+
auto tablet = std::static_pointer_cast<CloudTablet>(_tablet);
1474+
tablet->local_read_time_ms.fetch_add(_stats.cloud_local_read_time);
1475+
tablet->remote_read_time_ms.fetch_add(_stats.cloud_remote_read_time);
1476+
tablet->exec_compaction_time_ms.fetch_add(watch.get_elapse_time_us() / 1000);
1477+
14711478
return Status::OK();
14721479
}
14731480

be/src/olap/merger.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,10 @@ Status Merger::vmerge_rowsets(BaseTabletSPtr tablet, ReaderType reader_type,
145145
stats_output->merged_rows = reader.merged_rows();
146146
stats_output->filtered_rows = reader.filtered_rows();
147147
if (config::is_cloud_mode()) {
148-
stats_output->cloud_local_read_time = reader.stats().file_cache_stats.local_io_timer;
149-
stats_output->cloud_remote_read_time = reader.stats().file_cache_stats.remote_io_timer;
148+
stats_output->cloud_local_read_time =
149+
reader.stats().file_cache_stats.local_io_timer / 1000 / 1000;
150+
stats_output->cloud_remote_read_time =
151+
reader.stats().file_cache_stats.remote_io_timer / 1000 / 1000;
150152
}
151153
}
152154

@@ -325,8 +327,10 @@ Status Merger::vertical_compact_one_group(
325327
stats_output->merged_rows = reader.merged_rows();
326328
stats_output->filtered_rows = reader.filtered_rows();
327329
if (config::is_cloud_mode()) {
328-
stats_output->cloud_local_read_time = reader.stats().file_cache_stats.local_io_timer;
329-
stats_output->cloud_remote_read_time = reader.stats().file_cache_stats.remote_io_timer;
330+
stats_output->cloud_local_read_time =
331+
reader.stats().file_cache_stats.local_io_timer / 1000 / 1000;
332+
stats_output->cloud_remote_read_time =
333+
reader.stats().file_cache_stats.remote_io_timer / 1000 / 1000;
330334
}
331335
}
332336
RETURN_IF_ERROR(dst_rowset_writer->flush_columns(is_key));

0 commit comments

Comments
 (0)