Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn EventDescription into class #340

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f921ff1
summarize Events in PerfEvent & PerfEventInstance class
Jun 25, 2024
cf7a1e6
implement suggested changes in PerfEvent
Jul 23, 2024
ef26807
completely remove config() dependency, use event_provider as Event fa…
Jul 29, 2024
820daaa
fix build tests
Aug 6, 2024
20b5252
rephrase ExecutionScope name() msg, fix typo
Aug 8, 2024
4c11c7b
EventGuard: set_id() -> get_id()
Aug 8, 2024
a729250
add/remove const& where needed
Aug 23, 2024
60fe8b7
refactor event getter & setter
Aug 23, 2024
6042a50
remove overloaded helper for std::visit
Aug 23, 2024
031d97a
remove ret var in enable() and diable() method
Aug 23, 2024
9a04f93
combine each tracepoint & sysfs event factory functions
Aug 23, 2024
e67101e
no c-style casting
Aug 23, 2024
ecd976f
implement and use |= operator for Availability enum
Aug 23, 2024
3df7701
check for error in get_id()
Aug 23, 2024
d584c06
remove Event attribute from EventGuard
Aug 23, 2024
8d4ccb4
move time event constructor into factory function, generalize create_…
Sep 2, 2024
3e1e8d9
init fd_ in EventGuard constructor
Sep 2, 2024
2097275
replace bit with (1ull << x)
Sep 2, 2024
dac416a
include sorting
Sep 2, 2024
cf92a19
fix build tests
Sep 2, 2024
5748f4a
let read_file_or_else return an std::optional, rename to try_read_file
Sep 2, 2024
3c7330e
replace default constructed EventGuard instances with std::optional<E…
Sep 2, 2024
4e0b8e2
use move explicitly for EventGuard instances
Sep 16, 2024
7798068
fix build tests
Sep 17, 2024
7b2bb17
fix -Wmaybe-uninitialized for group and userspace EventGuards
Oct 14, 2024
734dc8d
fix comparison operators of Event
Oct 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ set(SOURCE_FILES
src/process_controller.cpp

src/perf/event_provider.cpp
src/perf/event.cpp

src/perf/bio/block_device.cpp
src/perf/counter/counter_provider.cpp
Expand All @@ -182,8 +183,8 @@ set(SOURCE_FILES

src/perf/sample/writer.cpp
src/perf/time/converter.cpp src/perf/time/reader.cpp
src/perf/tracepoint/format.cpp
src/perf/tracepoint/writer.cpp
src/perf/tracepoint/event.cpp
src/perf/syscall/writer.cpp

src/time/time.cpp
Expand Down
8 changes: 8 additions & 0 deletions include/lo2s/measurement_scope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum class MeasurementScopeType
NEC_METRIC,
BIO,
SYSCALL,
TRACEPOINT,
UNKNOWN
};

Expand Down Expand Up @@ -79,6 +80,11 @@ struct MeasurementScope
return { MeasurementScopeType::SYSCALL, s };
}

static MeasurementScope tracepoint(ExecutionScope s)
{
return { MeasurementScopeType::TRACEPOINT, s };
}

friend bool operator==(const MeasurementScope& lhs, const MeasurementScope& rhs)
{
return (lhs.scope == rhs.scope) && lhs.type == rhs.type;
Expand Down Expand Up @@ -111,6 +117,8 @@ struct MeasurementScope
return fmt::format("block layer I/O events for {}", scope.name());
case MeasurementScopeType::SYSCALL:
return fmt::format("syscall events for {}", scope.name());
case MeasurementScopeType::TRACEPOINT:
return fmt::format("tracepoints for {}", scope.name());
teto519f marked this conversation as resolved.
Show resolved Hide resolved
default:
throw new std::runtime_error("Unknown ExecutionScopeType!");
}
Expand Down
20 changes: 12 additions & 8 deletions include/lo2s/perf/bio/writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,14 @@ class Writer
}
}

std::vector<tracepoint::EventFormat> get_tracepoints()
std::vector<perf::tracepoint::TracepointEvent> get_tracepoints()
{

bio_queue_ = tracepoint::EventFormat("block:block_bio_queue");
bio_issue_ = tracepoint::EventFormat("block:block_rq_issue");
bio_complete_ = tracepoint::EventFormat("block:block_rq_complete");
bio_queue_ =
perf::EventProvider::instance().create_tracepoint_event("block:block_bio_queue");
bio_issue_ =
perf::EventProvider::instance().create_tracepoint_event("block:block_rq_issue");
bio_complete_ =
perf::EventProvider::instance().create_tracepoint_event("block:block_rq_complete");

return { bio_queue_, bio_issue_, bio_complete_ };
}
Expand All @@ -182,9 +184,11 @@ class Writer
trace::Trace& trace_;
time::Converter& time_converter_;

tracepoint::EventFormat bio_queue_;
tracepoint::EventFormat bio_issue_;
tracepoint::EventFormat bio_complete_;
// Unabailable until get_tracepoints() is called
teto519f marked this conversation as resolved.
Show resolved Hide resolved
perf::tracepoint::TracepointEvent bio_queue_;
perf::tracepoint::TracepointEvent bio_issue_;
perf::tracepoint::TracepointEvent bio_complete_;

// The unit "sector" is always 512 bit large, regardless of the actual sector size of the device
static constexpr int SECTOR_SIZE = 512;
};
Expand Down
10 changes: 5 additions & 5 deletions include/lo2s/perf/counter/counter_collection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#pragma once

#include <lo2s/perf/event_description.hpp>
#include <lo2s/perf/event.hpp>

#include <vector>

Expand All @@ -33,18 +33,18 @@ namespace counter
{
struct CounterCollection
{
EventDescription leader;
std::vector<EventDescription> counters;
Event leader;
std::vector<Event> counters;

double get_scale(int index) const
{
if (index == 0)
{
return leader.scale;
return leader.get_scale();
}
else
{
return counters[index - 1].scale;
return counters[index - 1].get_scale();
}
}

Expand Down
11 changes: 7 additions & 4 deletions include/lo2s/perf/counter/counter_provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <lo2s/measurement_scope.hpp>
#include <lo2s/perf/counter/counter_collection.hpp>
#include <lo2s/perf/event_description.hpp>
#include <lo2s/perf/tracepoint/event.hpp>

#include <vector>

Expand All @@ -49,16 +49,19 @@ class CounterProvider
void initialize_group_counters(const std::string& leader,
const std::vector<std::string>& counters);
void initialize_userspace_counters(const std::vector<std::string>& counters);
void initialize_tracepoints(const std::vector<std::string>& tracepoints);

bool has_group_counters(ExecutionScope scope);
bool has_userspace_counters(ExecutionScope scope);

CounterCollection collection_for(MeasurementScope scope);
std::vector<std::string> get_tracepoint_event_names();

private:
EventDescription group_leader_;
std::vector<EventDescription> group_events_;
std::vector<EventDescription> userspace_events_;
Event group_leader_;
std::vector<Event> group_events_;
std::vector<Event> userspace_events_;
std::vector<tracepoint::TracepointEvent> tracepoint_events_;
};
} // namespace counter
} // namespace perf
Expand Down
17 changes: 3 additions & 14 deletions include/lo2s/perf/counter/group/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <lo2s/perf/counter/counter_collection.hpp>
#include <lo2s/perf/counter/group/group_counter_buffer.hpp>
#include <lo2s/perf/event.hpp>
#include <lo2s/perf/event_reader.hpp>

#include <vector>
Expand Down Expand Up @@ -58,21 +59,9 @@ class Reader : public EventReader<T>
struct GroupReadFormat v;
};

~Reader()
{
for (int fd : counter_fds_)
{
if (fd != -1)
{
::close(fd);
}
}
::close(group_leader_fd_);
}

protected:
int group_leader_fd_;
std::vector<int> counter_fds_;
EventGuard counter_leader_;
std::vector<EventGuard> counters_;
CounterCollection counter_collection_;
GroupCounterBuffer counter_buffer_;
};
Expand Down
3 changes: 2 additions & 1 deletion include/lo2s/perf/counter/userspace/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <lo2s/execution_scope.hpp>
#include <lo2s/perf/counter/counter_collection.hpp>
#include <lo2s/perf/counter/userspace/userspace_counter_buffer.hpp>
#include <lo2s/perf/event_provider.hpp>
#include <lo2s/trace/trace.hpp>

#include <cstdint>
Expand Down Expand Up @@ -55,11 +56,11 @@ class Reader
}

protected:
std::vector<int> counter_fds_;
CounterCollection counter_collection_;
UserspaceCounterBuffer counter_buffer_;
int timer_fd_;

std::vector<EventGuard> counters_;
std::vector<UserspaceReadFormat> data_;
};
} // namespace userspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ namespace userspace
{
struct UserspaceReadFormat
{
UserspaceReadFormat() : value(0), time_enabled(0), time_running(0)
{
}

uint64_t value;
uint64_t time_enabled;
uint64_t time_running;
Expand Down
Loading
Loading