Skip to content

Commit

Permalink
fq: Add trace event
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
xemul committed Aug 30, 2024
1 parent d0daf23 commit 1cf0ddf
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/trace/decode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <seastar/util/trace.hh>
#include <seastar/core/byteorder.hh>
#include <seastar/core/internal/io_trace.hh>
#include <seastar/core/internal/fq_trace.hh>

using namespace seastar;

Expand All @@ -40,6 +41,8 @@ size_t event_body_size(internal::trace_event ev) {
return internal::event_tracer<internal::trace_event::IO_DISPATCH>::size();
case internal::trace_event::IO_COMPLETE:
return internal::event_tracer<internal::trace_event::IO_COMPLETE>::size();
case internal::trace_event::FQ_WAIT_CAPACITY:
return internal::event_tracer<internal::trace_event::FQ_WAIT_CAPACITY>::size();
case internal::trace_event::BUFFER_HEAD:
case internal::trace_event::OPENING:
case internal::trace_event::T800:
Expand Down Expand Up @@ -87,6 +90,11 @@ std::string parse<internal::trace_event::IO_COMPLETE>(temporary_buffer<char> bod
return format("IO C {:04x}", rq);
}

template<>
std::string parse<internal::trace_event::FQ_WAIT_CAPACITY>(temporary_buffer<char> body) {
return "FQ WAIT";
}

std::string parse_event(internal::trace_event ev, temporary_buffer<char> body) {
switch (ev) {
case internal::trace_event::TICK:
Expand All @@ -99,6 +107,8 @@ std::string parse_event(internal::trace_event ev, temporary_buffer<char> body) {
return parse<internal::trace_event::IO_DISPATCH>(std::move(body));
case internal::trace_event::IO_COMPLETE:
return parse<internal::trace_event::IO_COMPLETE>(std::move(body));
case internal::trace_event::FQ_WAIT_CAPACITY:
return parse<internal::trace_event::FQ_WAIT_CAPACITY>(std::move(body));
case internal::trace_event::BUFFER_HEAD:
case internal::trace_event::OPENING:
case internal::trace_event::T800:
Expand Down
37 changes: 37 additions & 0 deletions include/seastar/core/internal/fq_trace.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* This file is open source software, licensed to you under the terms
* of the Apache License, Version 2.0 (the "License"). See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. You may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/*
* Copyright (C) 2024 ScyllaDB.
*/


#pragma once
#include <seastar/util/trace.hh>

namespace seastar {
namespace internal {

template<>
struct event_tracer<trace_event::FQ_WAIT_CAPACITY> {
static int size() noexcept { return 0; }
static void put(char* buf) noexcept { }
};

} // internal namespace
} // seastar namespace
1 change: 1 addition & 0 deletions include/seastar/util/trace.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enum class trace_event {
IO_QUEUE,
IO_DISPATCH,
IO_COMPLETE,
FQ_WAIT_CAPACITY,
};

size_t tick_event_size();
Expand Down
1 change: 1 addition & 0 deletions src/core/fair_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ auto fair_queue::grab_capacity(const fair_queue_entry& ent) noexcept -> grab_res
capacity_t cap = ent._capacity;
capacity_t want_head = _group.grab_capacity(cap);
if (_group.capacity_deficiency(want_head)) {
_tracer.trace<internal::trace_event::FQ_WAIT_CAPACITY>();
_pending.emplace(want_head, cap);
return grab_result::pending;
}
Expand Down

0 comments on commit 1cf0ddf

Please sign in to comment.