[trace_processor] No-op refactor sched table gen to separate file
Test: Test: tools/diff_test_trace_processor.py out/android/trace_processor_shell
Change-Id: If0379901bc0b95bd9176214c8fb8bca73b04e112
diff --git a/Android.bp b/Android.bp
index b65d3fe..e53ee98 100644
--- a/Android.bp
+++ b/Android.bp
@@ -10283,6 +10283,7 @@
"src/trace_processor/tables/memory_tables.py",
"src/trace_processor/tables/metadata_tables.py",
"src/trace_processor/tables/profiler_tables.py",
+ "src/trace_processor/tables/sched_tables.py",
"src/trace_processor/tables/slice_tables.py",
"src/trace_processor/tables/trace_proto_tables.py",
"src/trace_processor/tables/track_tables.py",
@@ -10498,6 +10499,7 @@
"src/trace_processor/tables/memory_tables.py",
"src/trace_processor/tables/metadata_tables.py",
"src/trace_processor/tables/profiler_tables.py",
+ "src/trace_processor/tables/sched_tables.py",
"src/trace_processor/tables/slice_tables.py",
"src/trace_processor/tables/trace_proto_tables.py",
"src/trace_processor/tables/track_tables.py",
@@ -10513,6 +10515,7 @@
"src/trace_processor/tables/memory_tables_py.h",
"src/trace_processor/tables/metadata_tables_py.h",
"src/trace_processor/tables/profiler_tables_py.h",
+ "src/trace_processor/tables/sched_tables_py.h",
"src/trace_processor/tables/slice_tables_py.h",
"src/trace_processor/tables/trace_proto_tables_py.h",
"src/trace_processor/tables/track_tables_py.h",
@@ -10532,6 +10535,7 @@
"src/trace_processor/tables/memory_tables.py",
"src/trace_processor/tables/metadata_tables.py",
"src/trace_processor/tables/profiler_tables.py",
+ "src/trace_processor/tables/sched_tables.py",
"src/trace_processor/tables/slice_tables.py",
"src/trace_processor/tables/trace_proto_tables.py",
"src/trace_processor/tables/track_tables.py",
diff --git a/BUILD b/BUILD
index a62edb8..8097a66 100644
--- a/BUILD
+++ b/BUILD
@@ -2293,6 +2293,7 @@
"src/trace_processor/tables/memory_tables.py",
"src/trace_processor/tables/metadata_tables.py",
"src/trace_processor/tables/profiler_tables.py",
+ "src/trace_processor/tables/sched_tables.py",
"src/trace_processor/tables/slice_tables.py",
"src/trace_processor/tables/trace_proto_tables.py",
"src/trace_processor/tables/track_tables.py",
@@ -2304,6 +2305,7 @@
"src/trace_processor/tables/memory_tables_py.h",
"src/trace_processor/tables/metadata_tables_py.h",
"src/trace_processor/tables/profiler_tables_py.h",
+ "src/trace_processor/tables/sched_tables_py.h",
"src/trace_processor/tables/slice_tables_py.h",
"src/trace_processor/tables/trace_proto_tables_py.h",
"src/trace_processor/tables/track_tables_py.h",
diff --git a/src/trace_processor/importers/proto/android_camera_event_module.h b/src/trace_processor/importers/proto/android_camera_event_module.h
index 1d55081..e9df6c4 100644
--- a/src/trace_processor/importers/proto/android_camera_event_module.h
+++ b/src/trace_processor/importers/proto/android_camera_event_module.h
@@ -24,6 +24,7 @@
#include "protos/perfetto/trace/trace_packet.pbzero.h"
#include "src/trace_processor/importers/common/parser_types.h"
#include "src/trace_processor/importers/proto/proto_importer_module.h"
+#include "src/trace_processor/tables/sched_tables_py.h"
#include "src/trace_processor/tables/slice_tables_py.h"
#include "src/trace_processor/tables/track_tables_py.h"
#include "src/trace_processor/types/trace_processor_context.h"
diff --git a/src/trace_processor/importers/proto/statsd_module.h b/src/trace_processor/importers/proto/statsd_module.h
index 430b7a2..653c1eb 100644
--- a/src/trace_processor/importers/proto/statsd_module.h
+++ b/src/trace_processor/importers/proto/statsd_module.h
@@ -26,6 +26,7 @@
#include "src/trace_processor/importers/common/trace_parser.h"
#include "src/trace_processor/importers/proto/proto_importer_module.h"
#include "src/trace_processor/storage/trace_storage.h"
+#include "src/trace_processor/tables/sched_tables_py.h"
#include "src/trace_processor/tables/slice_tables_py.h"
#include "src/trace_processor/tables/track_tables_py.h"
#include "src/trace_processor/types/trace_processor_context.h"
diff --git a/src/trace_processor/prelude/table_functions/tables.py b/src/trace_processor/prelude/table_functions/tables.py
index 4ffc526..32e4550 100644
--- a/src/trace_processor/prelude/table_functions/tables.py
+++ b/src/trace_processor/prelude/table_functions/tables.py
@@ -28,7 +28,7 @@
from src.trace_processor.tables.metadata_tables import PROCESS_TABLE
from src.trace_processor.tables.profiler_tables import STACK_PROFILE_CALLSITE_TABLE
from src.trace_processor.tables.slice_tables import SLICE_TABLE
-from src.trace_processor.tables.slice_tables import SCHED_SLICE_TABLE
+from src.trace_processor.tables.sched_tables import SCHED_SLICE_TABLE
ANCESTOR_SLICE_TABLE = Table(
python_module=__file__,
diff --git a/src/trace_processor/storage/trace_storage.h b/src/trace_processor/storage/trace_storage.h
index ace9f1d..67bdd0b 100644
--- a/src/trace_processor/storage/trace_storage.h
+++ b/src/trace_processor/storage/trace_storage.h
@@ -42,6 +42,7 @@
#include "src/trace_processor/tables/memory_tables_py.h"
#include "src/trace_processor/tables/metadata_tables_py.h"
#include "src/trace_processor/tables/profiler_tables_py.h"
+#include "src/trace_processor/tables/sched_tables_py.h"
#include "src/trace_processor/tables/slice_tables_py.h"
#include "src/trace_processor/tables/trace_proto_tables_py.h"
#include "src/trace_processor/tables/track_tables_py.h"
diff --git a/src/trace_processor/tables/BUILD.gn b/src/trace_processor/tables/BUILD.gn
index 9ec397f..b8d69a8 100644
--- a/src/trace_processor/tables/BUILD.gn
+++ b/src/trace_processor/tables/BUILD.gn
@@ -23,6 +23,7 @@
"memory_tables.py",
"metadata_tables.py",
"profiler_tables.py",
+ "sched_tables.py",
"slice_tables.py",
"trace_proto_tables.py",
"track_tables.py",
diff --git a/src/trace_processor/tables/sched_tables.py b/src/trace_processor/tables/sched_tables.py
new file mode 100644
index 0000000..d65c8be
--- /dev/null
+++ b/src/trace_processor/tables/sched_tables.py
@@ -0,0 +1,166 @@
+# Copyright (C) 2023 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# 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.
+"""Contains tables for relevant for sched."""
+
+from python.generators.trace_processor_table.public import Column as C
+from python.generators.trace_processor_table.public import ColumnDoc
+from python.generators.trace_processor_table.public import ColumnFlag
+from python.generators.trace_processor_table.public import CppInt32
+from python.generators.trace_processor_table.public import CppInt64
+from python.generators.trace_processor_table.public import CppOptional
+from python.generators.trace_processor_table.public import CppSelfTableId
+from python.generators.trace_processor_table.public import CppString
+from python.generators.trace_processor_table.public import CppTableId
+from python.generators.trace_processor_table.public import CppUint32
+from python.generators.trace_processor_table.public import Table
+from python.generators.trace_processor_table.public import TableDoc
+from python.generators.trace_processor_table.public import WrappingSqlView
+
+SCHED_SLICE_TABLE = Table(
+ python_module=__file__,
+ class_name='SchedSliceTable',
+ sql_name='sched_slice',
+ columns=[
+ C('ts', CppInt64(), flags=ColumnFlag.SORTED),
+ C('dur', CppInt64()),
+ C('cpu', CppUint32()),
+ C('utid', CppUint32()),
+ C('end_state', CppString()),
+ C('priority', CppInt32()),
+ ],
+ tabledoc=TableDoc(
+ doc='''
+ This table holds slices with kernel thread scheduling information.
+ These slices are collected when the Linux "ftrace" data source is
+ used with the "sched/switch" and "sched/wakeup*" events enabled.
+
+ The rows in this table will always have a matching row in the
+ |thread_state| table with |thread_state.state| = 'Running'
+ ''',
+ group='Events',
+ columns={
+ 'ts':
+ '''The timestamp at the start of the slice (in nanoseconds).''',
+ 'dur':
+ '''The duration of the slice (in nanoseconds).''',
+ 'utid':
+ '''The thread's unique id in the trace..''',
+ 'cpu':
+ '''The CPU that the slice executed on.''',
+ 'end_state':
+ '''
+ A string representing the scheduling state of the kernel
+ thread at the end of the slice. The individual characters in
+ the string mean the following: R (runnable), S (awaiting a
+ wakeup), D (in an uninterruptible sleep), T (suspended),
+ t (being traced), X (exiting), P (parked), W (waking),
+ I (idle), N (not contributing to the load average),
+ K (wakeable on fatal signals) and Z (zombie, awaiting
+ cleanup).
+ ''',
+ 'priority':
+ '''The kernel priority that the thread ran at.'''
+ }))
+
+SPURIOUS_SCHED_WAKEUP_TABLE = Table(
+ python_module=__file__,
+ class_name='SpuriousSchedWakeupTable',
+ sql_name='spurious_sched_wakeup',
+ columns=[
+ C('ts', CppInt64(), flags=ColumnFlag.SORTED),
+ C('thread_state_id', CppInt64()),
+ C('irq_context', CppOptional(CppUint32())),
+ C('utid', CppUint32()),
+ C('waker_utid', CppUint32()),
+ ],
+ tabledoc=TableDoc(
+ doc='''
+ This table contains the scheduling wakeups that occurred while a thread was
+ not blocked, i.e. running or runnable. Such wakeups are not tracked in the
+ |thread_state_table|.
+ ''',
+ group='Events',
+ columns={
+ 'ts':
+ 'The timestamp at the start of the slice (in nanoseconds).',
+ 'thread_state_id':
+ 'The id of the row in the thread_state table that this row is associated with.',
+ 'irq_context':
+ '''Whether the wakeup was from interrupt context or process context.''',
+ 'utid':
+ '''The thread's unique id in the trace..''',
+ 'waker_utid':
+ '''
+ The unique thread id of the thread which caused a wakeup of
+ this thread.
+ '''
+ }))
+
+THREAD_STATE_TABLE = Table(
+ python_module=__file__,
+ class_name='ThreadStateTable',
+ sql_name='thread_state',
+ columns=[
+ C('ts', CppInt64(), flags=ColumnFlag.SORTED),
+ C('dur', CppInt64()),
+ C('cpu', CppOptional(CppUint32())),
+ C('utid', CppUint32()),
+ C('state', CppString()),
+ C('io_wait', CppOptional(CppUint32())),
+ C('blocked_function', CppOptional(CppString())),
+ C('waker_utid', CppOptional(CppUint32())),
+ C('irq_context', CppOptional(CppUint32())),
+ ],
+ tabledoc=TableDoc(
+ doc='''
+ This table contains the scheduling state of every thread on the
+ system during the trace.
+
+ The rows in this table which have |state| = 'Running', will have a
+ corresponding row in the |sched_slice| table.
+ ''',
+ group='Events',
+ columns={
+ 'ts':
+ 'The timestamp at the start of the slice (in nanoseconds).',
+ 'dur':
+ 'The duration of the slice (in nanoseconds).',
+ 'cpu':
+ '''The CPU that the slice executed on.''',
+ 'irq_context':
+ '''Whether the wakeup was from interrupt context or process context.''',
+ 'utid':
+ '''The thread's unique id in the trace..''',
+ 'state':
+ '''
+ The scheduling state of the thread. Can be "Running" or any
+ of the states described in |sched_slice.end_state|.
+ ''',
+ 'io_wait':
+ 'Indicates whether this thread was blocked on IO.',
+ 'blocked_function':
+ 'The function in the kernel this thread was blocked on.',
+ 'waker_utid':
+ '''
+ The unique thread id of the thread which caused a wakeup of
+ this thread.
+ '''
+ }))
+
+# Keep this list sorted.
+ALL_TABLES = [
+ SCHED_SLICE_TABLE,
+ SPURIOUS_SCHED_WAKEUP_TABLE,
+ THREAD_STATE_TABLE,
+]
diff --git a/src/trace_processor/tables/slice_tables.py b/src/trace_processor/tables/slice_tables.py
index eec99c6..f1a4d90 100644
--- a/src/trace_processor/tables/slice_tables.py
+++ b/src/trace_processor/tables/slice_tables.py
@@ -120,137 +120,6 @@
''',
}))
-SCHED_SLICE_TABLE = Table(
- python_module=__file__,
- class_name='SchedSliceTable',
- sql_name='sched_slice',
- columns=[
- C('ts', CppInt64(), flags=ColumnFlag.SORTED),
- C('dur', CppInt64()),
- C('cpu', CppUint32()),
- C('utid', CppUint32()),
- C('end_state', CppString()),
- C('priority', CppInt32()),
- ],
- tabledoc=TableDoc(
- doc='''
- This table holds slices with kernel thread scheduling information.
- These slices are collected when the Linux "ftrace" data source is
- used with the "sched/switch" and "sched/wakeup*" events enabled.
-
- The rows in this table will always have a matching row in the
- |thread_state| table with |thread_state.state| = 'Running'
- ''',
- group='Events',
- columns={
- 'ts':
- '''The timestamp at the start of the slice (in nanoseconds).''',
- 'dur':
- '''The duration of the slice (in nanoseconds).''',
- 'utid':
- '''The thread's unique id in the trace..''',
- 'cpu':
- '''The CPU that the slice executed on.''',
- 'end_state':
- '''
- A string representing the scheduling state of the kernel
- thread at the end of the slice. The individual characters in
- the string mean the following: R (runnable), S (awaiting a
- wakeup), D (in an uninterruptible sleep), T (suspended),
- t (being traced), X (exiting), P (parked), W (waking),
- I (idle), N (not contributing to the load average),
- K (wakeable on fatal signals) and Z (zombie, awaiting
- cleanup).
- ''',
- 'priority':
- '''The kernel priority that the thread ran at.'''
- }))
-
-THREAD_STATE_TABLE = Table(
- python_module=__file__,
- class_name='ThreadStateTable',
- sql_name='thread_state',
- columns=[
- C('ts', CppInt64(), flags=ColumnFlag.SORTED),
- C('dur', CppInt64()),
- C('cpu', CppOptional(CppUint32())),
- C('utid', CppUint32()),
- C('state', CppString()),
- C('io_wait', CppOptional(CppUint32())),
- C('blocked_function', CppOptional(CppString())),
- C('waker_utid', CppOptional(CppUint32())),
- C('irq_context', CppOptional(CppUint32())),
- ],
- tabledoc=TableDoc(
- doc='''
- This table contains the scheduling state of every thread on the
- system during the trace.
-
- The rows in this table which have |state| = 'Running', will have a
- corresponding row in the |sched_slice| table.
- ''',
- group='Events',
- columns={
- 'ts':
- 'The timestamp at the start of the slice (in nanoseconds).',
- 'dur':
- 'The duration of the slice (in nanoseconds).',
- 'cpu':
- '''The CPU that the slice executed on.''',
- 'irq_context':
- '''Whether the wakeup was from interrupt context or process context.''',
- 'utid':
- '''The thread's unique id in the trace..''',
- 'state':
- '''
- The scheduling state of the thread. Can be "Running" or any
- of the states described in |sched_slice.end_state|.
- ''',
- 'io_wait':
- 'Indicates whether this thread was blocked on IO.',
- 'blocked_function':
- 'The function in the kernel this thread was blocked on.',
- 'waker_utid':
- '''
- The unique thread id of the thread which caused a wakeup of
- this thread.
- '''
- }))
-
-SPURIOUS_SCHED_WAKEUP_TABLE = Table(
- python_module=__file__,
- class_name='SpuriousSchedWakeupTable',
- sql_name='spurious_sched_wakeup',
- columns=[
- C('ts', CppInt64(), flags=ColumnFlag.SORTED),
- C('thread_state_id', CppInt64()),
- C('irq_context', CppOptional(CppUint32())),
- C('utid', CppUint32()),
- C('waker_utid', CppUint32()),
- ],
- tabledoc=TableDoc(
- doc='''
- This table contains the scheduling wakeups that occurred while a thread was
- not blocked, i.e. running or runnable. Such wakeups are not tracked in the
- |thread_state_table|.
- ''',
- group='Events',
- columns={
- 'ts':
- 'The timestamp at the start of the slice (in nanoseconds).',
- 'thread_state_id':
- 'The id of the row in the thread_state table that this row is associated with.',
- 'irq_context':
- '''Whether the wakeup was from interrupt context or process context.''',
- 'utid':
- '''The thread's unique id in the trace..''',
- 'waker_utid':
- '''
- The unique thread id of the thread which caused a wakeup of
- this thread.
- '''
- }))
-
GPU_SLICE_TABLE = Table(
python_module=__file__,
class_name='GpuSliceTable',
@@ -417,8 +286,5 @@
EXPERIMENTAL_FLAT_SLICE_TABLE,
GPU_SLICE_TABLE,
GRAPHICS_FRAME_SLICE_TABLE,
- SCHED_SLICE_TABLE,
SLICE_TABLE,
- THREAD_STATE_TABLE,
- SPURIOUS_SCHED_WAKEUP_TABLE,
]
diff --git a/src/trace_processor/tables/table_destructors.cc b/src/trace_processor/tables/table_destructors.cc
index 0ecc3cd..ba57b22 100644
--- a/src/trace_processor/tables/table_destructors.cc
+++ b/src/trace_processor/tables/table_destructors.cc
@@ -20,6 +20,7 @@
#include "src/trace_processor/tables/memory_tables_py.h"
#include "src/trace_processor/tables/metadata_tables_py.h"
#include "src/trace_processor/tables/profiler_tables_py.h"
+#include "src/trace_processor/tables/sched_tables_py.h"
#include "src/trace_processor/tables/slice_tables_py.h"
#include "src/trace_processor/tables/trace_proto_tables_py.h"
#include "src/trace_processor/tables/track_tables_py.h"
@@ -71,14 +72,16 @@
ProfilerSmapsTable::~ProfilerSmapsTable() = default;
GpuCounterGroupTable::~GpuCounterGroupTable() = default;
+// sched_tables_py.h
+SchedSliceTable::~SchedSliceTable() = default;
+SpuriousSchedWakeupTable::~SpuriousSchedWakeupTable() = default;
+ThreadStateTable::~ThreadStateTable() = default;
+
// slice_tables_py.h
SliceTable::~SliceTable() = default;
FlowTable::~FlowTable() = default;
-SchedSliceTable::~SchedSliceTable() = default;
-SpuriousSchedWakeupTable::~SpuriousSchedWakeupTable() = default;
GpuSliceTable::~GpuSliceTable() = default;
GraphicsFrameSliceTable::~GraphicsFrameSliceTable() = default;
-ThreadStateTable::~ThreadStateTable() = default;
ExpectedFrameTimelineSliceTable::~ExpectedFrameTimelineSliceTable() = default;
ActualFrameTimelineSliceTable::~ActualFrameTimelineSliceTable() = default;
ExperimentalFlatSliceTable::~ExperimentalFlatSliceTable() = default;