From e37441966550e8db6b31c9fd6d7e1ac4e06257aa Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Tue, 31 Dec 2019 13:19:31 -0500 Subject: [PATCH] Make required events a set --- .../tracetools_analysis/processor/__init__.py | 6 +++--- .../tracetools_analysis/processor/cpu_time.py | 8 ++++---- .../tracetools_analysis/processor/memory_usage.py | 14 +++++++------- .../tracetools_analysis/processor/profile.py | 7 ++++--- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/tracetools_analysis/tracetools_analysis/processor/__init__.py b/tracetools_analysis/tracetools_analysis/processor/__init__.py index 3ca4104..fd3466a 100644 --- a/tracetools_analysis/tracetools_analysis/processor/__init__.py +++ b/tracetools_analysis/tracetools_analysis/processor/__init__.py @@ -138,14 +138,14 @@ class EventHandler(Dependant): return None @staticmethod - def required_events() -> List[str]: + def required_events() -> Set[str]: """ - Get the list of events required by this EventHandler. + Get the set of events required by this EventHandler. Without these events, the EventHandler would be invalid/useless. Inheriting classes can decide not to declare that they require specific events. """ - return [] + return {} def register_processor(self, processor: 'Processor') -> None: """Register processor with this `EventHandler` so that it can query other handlers.""" diff --git a/tracetools_analysis/tracetools_analysis/processor/cpu_time.py b/tracetools_analysis/tracetools_analysis/processor/cpu_time.py index d842ac3..ea77954 100644 --- a/tracetools_analysis/tracetools_analysis/processor/cpu_time.py +++ b/tracetools_analysis/tracetools_analysis/processor/cpu_time.py @@ -15,7 +15,7 @@ """Module for CPU time events processing.""" from typing import Dict -from typing import List +from typing import Set from tracetools_read import get_field @@ -53,10 +53,10 @@ class CpuTimeHandler(EventHandler): self._cpu_start: Dict[int, int] = {} @staticmethod - def required_events() -> List[str]: - return [ + def required_events() -> Set[str]: + return { 'sched_switch', - ] + } @property def data(self) -> CpuTimeDataModel: diff --git a/tracetools_analysis/tracetools_analysis/processor/memory_usage.py b/tracetools_analysis/tracetools_analysis/processor/memory_usage.py index 4d2b1ee..a7a30b5 100644 --- a/tracetools_analysis/tracetools_analysis/processor/memory_usage.py +++ b/tracetools_analysis/tracetools_analysis/processor/memory_usage.py @@ -15,7 +15,7 @@ """Module for memory usage events processing.""" from typing import Dict -from typing import List +from typing import Set from tracetools_read import get_field @@ -98,11 +98,11 @@ class UserspaceMemoryUsageHandler(MemoryUsageHandler): self._memory: Dict[int, int] = {} @staticmethod - def required_events() -> List[str]: - return [ + def required_events() -> Set[str]: + return { 'lttng_ust_libc:malloc', 'lttng_ust_libc:free', - ] + } def _handle_malloc( self, event: Dict, metadata: EventMetadata @@ -209,11 +209,11 @@ class KernelMemoryUsageHandler(MemoryUsageHandler): ) @staticmethod - def required_events() -> List[str]: - return [ + def required_events() -> Set[str]: + return { 'kmem_mm_page_alloc', 'kmem_mm_page_free', - ] + } def _handle_malloc( self, event: Dict, metadata: EventMetadata diff --git a/tracetools_analysis/tracetools_analysis/processor/profile.py b/tracetools_analysis/tracetools_analysis/processor/profile.py index 1ed4b1a..2f08611 100644 --- a/tracetools_analysis/tracetools_analysis/processor/profile.py +++ b/tracetools_analysis/tracetools_analysis/processor/profile.py @@ -17,6 +17,7 @@ from collections import defaultdict from typing import Dict from typing import List +from typing import Set from typing import Union from tracetools_read import get_field @@ -87,12 +88,12 @@ class ProfileHandler(EventHandler): self._current_funcs: Dict[int, List[List[Union[str, int]]]] = defaultdict(list) @staticmethod - def required_events() -> List[str]: - return [ + def required_events() -> Set[str]: + return { 'lttng_ust_cyg_profile_fast:func_entry', 'lttng_ust_cyg_profile_fast:func_exit', 'sched_switch', - ] + } @staticmethod def addr_to_int(addr: Union[int, str]) -> int: