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

Fix various remaining issues with EventDescription Rework, streamline interfaces, move configuration of Events in own EventConfig class. #358

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

cvonelm
Copy link
Member

@cvonelm cvonelm commented Jan 22, 2025

#Move Event Configuration to EventConfig class

Designwise, the EventConfig class should handle all the ugly details of
configuring the Events from the given Config(), such as setting specific
bits.

The sample::Reader for example asks the EventConfig for a sample event.
The EventConfig then selects the correct sampling event using the
EventProvider and the Config, configures all the options, such as
sample_period and then gives it back to the sample::Reader.
The sample::Reader does not need to change anything about the event.

The EventProvider should only provide events, reading them from
different sources, such as pre-defined, PFM, PMU events.

The CounterProvider did not do anything special enough to warrant its
continuing existence, merge it with EventConfig

Smaller fixes
- delete needless getter in CounterCollection
- provide default values for bools in Config()
- check exclude_kernel once in EventConfig() instead of for every event

Test for debugfs when specifying tracepoint dependent options,

print [CPUS 0-0] as [CPU 0]

Refactor Event class

- Make Event clean base class. Use SimpleEvent when the  event configuration needs to
  be specified manually.
- Move almost all logic outside of the Event class. Event Configuration
  should happen fully from the outside
- fix boolean operators
- move sysfs specific code from Event to SysfsEvent

Pass TracepointEvent directly instead of name of event

Also move use-case specific tracepoint code out of TracepointEvent

Add definition of base_path into read_proc()

Somehow, base_path does not get initialized correctly before read_proc
is called, so move it all into read_proc

@cvonelm cvonelm force-pushed the fix_perf_event branch 3 times, most recently from bc45d53 to 2f1196c Compare January 24, 2025 08:53
Somehow, base_path does not get initialized correctly before read_proc
is called, so move it all into read_proc
Also move use-case specific tracepoint code out of TracepointEvent
- Make Event clean base class. Use SimpleEvent when the  event configuration needs to
  be specified manually.
- Move almost all logic outside of the Event class. Event Configuration
  should happen fully from the outside
- fix boolean operators
- move sysfs specific code from Event to SysfsEvent
Designwise, the EventConfig class should handle all the ugly details of
configuring the Events from the given Config(), such as setting specific
bits.

The sample::Reader for example asks the EventConfig for a sample event.
The EventConfig then selects the correct sampling event using the
EventProvider and the Config, configures all the options, such as
sample_period and then gives it back to the sample::Reader.
The sample::Reader does not need to change anything about the event.

The EventProvider should only provide events, reading them from
different sources, such as pre-defined, PFM, PMU events.

The CounterProvider did not do anything special enough to warrant its
continuing existence, merge it with EventConfig

Smaller fixes
- delete needless getter in CounterCollection
- provide default values for bools in Config()
- check exclude_kernel once in EventConfig() instead of for every event
Copy link
Member

@bmario bmario left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you finally lost me with the naming.

What do the Event instances represent? (And their subclass instances)
What is the difference between EventProvider and EventConfig?

include/lo2s/config.hpp Show resolved Hide resolved
include/lo2s/perf/event.hpp Outdated Show resolved Hide resolved
include/lo2s/perf/pfm.hpp Outdated Show resolved Hide resolved
include/lo2s/perf/sample/reader.hpp Outdated Show resolved Hide resolved
src/config.cpp Outdated Show resolved Hide resolved
include/lo2s/perf/event.hpp Outdated Show resolved Hide resolved
include/lo2s/perf/event_config.hpp Outdated Show resolved Hide resolved
Comment on lines 55 to 58
void watermark(Event& ev)
{
ev.set_watermark(0.8 * config().mmap_pages * sysconf(_SC_PAGESIZE));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here? It seems to be not worth a function on its own. Especially because the name is not really telling.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use this calculation for the watermark at three different spots in the code and I dont want to spread the arcane knowledge that watermark is 80% of config().mmap_pages * page_size all through the code.

include/lo2s/perf/event.hpp Outdated Show resolved Hide resolved
include/lo2s/perf/event_config.hpp Outdated Show resolved Hide resolved
@bmario
Copy link
Member

bmario commented Jan 27, 2025

Also, I hate inheritance. Why is a SimpleEvent an Extension of an Event? How does one become simple by extending?

{Tracepoint, Breakpoint, Simple}Event -> EventAttr

EventConfig -> EventComposer
EventProvider -> EventResolver

also, make it impossible for invalid EventAttrs to exist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants