Coverage Report

Created: 2026-03-20 12:54

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exec/operator/spill_counters.h
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
#include "runtime/runtime_profile.h"
20
#include "runtime/runtime_profile_counter_names.h"
21
22
namespace doris {
23
24
// Shared spill write counters, used by both PipelineXSpillLocalState (source)
25
// and PipelineXSpillSinkLocalState (sink) to eliminate duplicated counter definitions.
26
struct SpillWriteCounters {
27
    RuntimeProfile::Counter* spill_write_timer = nullptr;
28
    RuntimeProfile::Counter* spill_write_wait_in_queue_task_count = nullptr;
29
    RuntimeProfile::Counter* spill_writing_task_count = nullptr;
30
    RuntimeProfile::Counter* spill_write_wait_in_queue_timer = nullptr;
31
    RuntimeProfile::Counter* spill_write_file_timer = nullptr;
32
    RuntimeProfile::Counter* spill_write_serialize_block_timer = nullptr;
33
    RuntimeProfile::Counter* spill_write_block_count = nullptr;
34
    RuntimeProfile::Counter* spill_write_block_data_size = nullptr;
35
    RuntimeProfile::Counter* spill_write_rows_count = nullptr;
36
37
112
    void init(RuntimeProfile* profile) {
38
112
        spill_write_timer = ADD_TIMER_WITH_LEVEL(profile, profile::SPILL_WRITE_TIME, 1);
39
112
        spill_write_wait_in_queue_task_count = ADD_COUNTER_WITH_LEVEL(
40
112
                profile, profile::SPILL_WRITE_TASK_WAIT_IN_QUEUE_COUNT, TUnit::UNIT, 1);
41
112
        spill_writing_task_count =
42
112
                ADD_COUNTER_WITH_LEVEL(profile, profile::SPILL_WRITE_TASK_COUNT, TUnit::UNIT, 1);
43
112
        spill_write_wait_in_queue_timer =
44
112
                ADD_TIMER_WITH_LEVEL(profile, profile::SPILL_WRITE_TASK_WAIT_IN_QUEUE_TIME, 1);
45
112
        spill_write_file_timer = ADD_TIMER_WITH_LEVEL(profile, profile::SPILL_WRITE_FILE_TIME, 1);
46
112
        spill_write_serialize_block_timer =
47
112
                ADD_TIMER_WITH_LEVEL(profile, profile::SPILL_WRITE_SERIALIZE_BLOCK_TIME, 1);
48
112
        spill_write_block_count =
49
112
                ADD_COUNTER_WITH_LEVEL(profile, profile::SPILL_WRITE_BLOCK_COUNT, TUnit::UNIT, 1);
50
112
        spill_write_block_data_size =
51
112
                ADD_COUNTER_WITH_LEVEL(profile, profile::SPILL_WRITE_BLOCK_BYTES, TUnit::BYTES, 1);
52
112
        spill_write_rows_count =
53
112
                ADD_COUNTER_WITH_LEVEL(profile, profile::SPILL_WRITE_ROWS, TUnit::UNIT, 1);
54
112
    }
55
};
56
57
// Shared spill read counters, used only by PipelineXSpillLocalState (source).
58
struct SpillReadCounters {
59
    RuntimeProfile::Counter* spill_recover_time = nullptr;
60
    RuntimeProfile::Counter* spill_read_wait_in_queue_task_count = nullptr;
61
    RuntimeProfile::Counter* spill_reading_task_count = nullptr;
62
    RuntimeProfile::Counter* spill_read_wait_in_queue_timer = nullptr;
63
    RuntimeProfile::Counter* spill_read_file_time = nullptr;
64
    RuntimeProfile::Counter* spill_read_deserialize_block_timer = nullptr;
65
    RuntimeProfile::Counter* spill_read_block_count = nullptr;
66
    RuntimeProfile::Counter* spill_read_block_data_size = nullptr;
67
    RuntimeProfile::Counter* spill_read_file_size = nullptr;
68
    RuntimeProfile::Counter* spill_read_rows_count = nullptr;
69
    RuntimeProfile::Counter* spill_read_file_count = nullptr;
70
71
68
    void init(RuntimeProfile* profile) {
72
68
        spill_recover_time = ADD_TIMER_WITH_LEVEL(profile, profile::SPILL_RECOVER_TIME, 1);
73
68
        spill_read_wait_in_queue_task_count = ADD_COUNTER_WITH_LEVEL(
74
68
                profile, profile::SPILL_READ_TASK_WAIT_IN_QUEUE_COUNT, TUnit::UNIT, 1);
75
68
        spill_reading_task_count =
76
68
                ADD_COUNTER_WITH_LEVEL(profile, profile::SPILL_READ_TASK_COUNT, TUnit::UNIT, 1);
77
68
        spill_read_wait_in_queue_timer =
78
68
                ADD_TIMER_WITH_LEVEL(profile, profile::SPILL_READ_TASK_WAIT_IN_QUEUE_TIME, 1);
79
68
        spill_read_file_time = ADD_TIMER_WITH_LEVEL(profile, profile::SPILL_READ_FILE_TIME, 1);
80
68
        spill_read_deserialize_block_timer =
81
68
                ADD_TIMER_WITH_LEVEL(profile, profile::SPILL_READ_DESERIALIZE_BLOCK_TIME, 1);
82
68
        spill_read_block_count =
83
68
                ADD_COUNTER_WITH_LEVEL(profile, profile::SPILL_READ_BLOCK_COUNT, TUnit::UNIT, 1);
84
68
        spill_read_block_data_size =
85
68
                ADD_COUNTER_WITH_LEVEL(profile, profile::SPILL_READ_BLOCK_BYTES, TUnit::BYTES, 1);
86
68
        spill_read_file_size =
87
68
                ADD_COUNTER_WITH_LEVEL(profile, profile::SPILL_READ_FILE_BYTES, TUnit::BYTES, 1);
88
68
        spill_read_rows_count =
89
68
                ADD_COUNTER_WITH_LEVEL(profile, profile::SPILL_READ_ROWS, TUnit::UNIT, 1);
90
68
        spill_read_file_count =
91
68
                ADD_COUNTER_WITH_LEVEL(profile, profile::SPILL_READ_FILE_COUNT, TUnit::UNIT, 1);
92
68
    }
93
};
94
95
} // namespace doris