Skip to content

Commit cdd9734

Browse files
committed
fq: Add trace event
There's only one interesting event for it -- when the queue goes "pending" state waiting for shared capacity. No arguments here, so it just takes 3 bytes in the buffer. Signed-off-by: Pavel Emelyanov <[email protected]>
1 parent 197f436 commit cdd9734

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

Diff for: apps/trace/decode.cc

+10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <seastar/util/trace.hh>
2626
#include <seastar/core/byteorder.hh>
2727
#include <seastar/core/internal/io_trace.hh>
28+
#include <seastar/core/internal/fq_trace.hh>
2829

2930
using namespace seastar;
3031

@@ -40,6 +41,8 @@ size_t event_body_size(internal::trace_event ev) {
4041
return internal::event_tracer<internal::trace_event::IO_DISPATCH>::size();
4142
case internal::trace_event::IO_COMPLETE:
4243
return internal::event_tracer<internal::trace_event::IO_COMPLETE>::size();
44+
case internal::trace_event::FQ_WAIT_CAPACITY:
45+
return internal::event_tracer<internal::trace_event::FQ_WAIT_CAPACITY>::size();
4346
case internal::trace_event::BUFFER_HEAD:
4447
case internal::trace_event::OPENING:
4548
case internal::trace_event::T800:
@@ -87,6 +90,11 @@ std::string parse<internal::trace_event::IO_COMPLETE>(temporary_buffer<char> bod
8790
return format("IO C {:04x}", rq);
8891
}
8992

93+
template<>
94+
std::string parse<internal::trace_event::FQ_WAIT_CAPACITY>(temporary_buffer<char> body) {
95+
return "FQ WAIT";
96+
}
97+
9098
std::string parse_event(internal::trace_event ev, temporary_buffer<char> body) {
9199
switch (ev) {
92100
case internal::trace_event::TICK:
@@ -99,6 +107,8 @@ std::string parse_event(internal::trace_event ev, temporary_buffer<char> body) {
99107
return parse<internal::trace_event::IO_DISPATCH>(std::move(body));
100108
case internal::trace_event::IO_COMPLETE:
101109
return parse<internal::trace_event::IO_COMPLETE>(std::move(body));
110+
case internal::trace_event::FQ_WAIT_CAPACITY:
111+
return parse<internal::trace_event::FQ_WAIT_CAPACITY>(std::move(body));
102112
case internal::trace_event::BUFFER_HEAD:
103113
case internal::trace_event::OPENING:
104114
case internal::trace_event::T800:

Diff for: include/seastar/core/internal/fq_trace.hh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* This file is open source software, licensed to you under the terms
3+
* of the Apache License, Version 2.0 (the "License"). See the NOTICE file
4+
* distributed with this work for additional information regarding copyright
5+
* ownership. You may not use this file except in compliance with the License.
6+
*
7+
* 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+
19+
/*
20+
* Copyright (C) 2024 ScyllaDB.
21+
*/
22+
23+
24+
#pragma once
25+
#include <seastar/util/trace.hh>
26+
27+
namespace seastar {
28+
namespace internal {
29+
30+
template<>
31+
struct event_tracer<trace_event::FQ_WAIT_CAPACITY> {
32+
static int size() noexcept { return 0; }
33+
static void put(char* buf) noexcept { }
34+
};
35+
36+
} // internal namespace
37+
} // seastar namespace

Diff for: include/seastar/util/trace.hh

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum class trace_event {
4343
IO_QUEUE,
4444
IO_DISPATCH,
4545
IO_COMPLETE,
46+
FQ_WAIT_CAPACITY,
4647
};
4748

4849
size_t tick_event_size();

Diff for: src/core/fair_queue.cc

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ auto fair_queue::grab_capacity(const fair_queue_entry& ent) noexcept -> grab_res
249249
capacity_t cap = ent._capacity;
250250
capacity_t want_head = _group.grab_capacity(cap);
251251
if (_group.capacity_deficiency(want_head)) {
252+
_tracer.trace<internal::trace_event::FQ_WAIT_CAPACITY>();
252253
_pending.emplace(want_head, cap);
253254
return grab_result::pending;
254255
}

0 commit comments

Comments
 (0)