diff options
author | Yan Wang <yawanng@google.com> | 2019-07-16 15:29:08 -0700 |
---|---|---|
committer | Yan Wang <yawanng@google.com> | 2019-07-17 15:47:54 -0700 |
commit | 315ae2d4c4396fa4f19f5a2be0d73afb9cfa7b31 (patch) | |
tree | 9709dd02de97377349c53eee645e100d58585e68 /startop/scripts/trace_analyzer/lib/trace2db.py | |
parent | ede8b187e99c9b68841d036d0045fee5bd1e1e82 (diff) |
Add support of trace duration for host python compiler.
The basic idea is add timestamp for MmFilemapAddToPageCache.
Treat the first receiving MmFilemapAddToPageCache timestamp as
the start time. The end time is the sum of start time and duration.
Any MmFilemapAddToPageCache after end time is filtered out.
Test: pytest trace2db_test.py
Bug: 137398235
Change-Id: Ib9c439f3ae0ca666eacb08492361217d89adec34
Diffstat (limited to 'startop/scripts/trace_analyzer/lib/trace2db.py')
-rw-r--r-- | startop/scripts/trace_analyzer/lib/trace2db.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/startop/scripts/trace_analyzer/lib/trace2db.py b/startop/scripts/trace_analyzer/lib/trace2db.py index f60d6ab5245b..42a33aff046d 100644 --- a/startop/scripts/trace_analyzer/lib/trace2db.py +++ b/startop/scripts/trace_analyzer/lib/trace2db.py @@ -19,6 +19,7 @@ import sys from sqlalchemy import create_engine from sqlalchemy import Column, Date, Integer, Float, String, ForeignKey from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import relationship from sqlalchemy.orm import sessionmaker @@ -43,6 +44,10 @@ class RawFtraceEntry(Base): function = Column(String, nullable=False) function_args = Column(String, nullable=False) + # 1:1 relation with MmFilemapAddToPageCache. + mm_filemap_add_to_page_cache = relationship("MmFilemapAddToPageCache", + back_populates="raw_ftrace_entry") + @staticmethod def parse_dict(line): # ' <...>-5521 (-----) [003] ...1 17148.446877: tracing_mark_write: trace_event_clock_sync: parent_ts=17148.447266' @@ -155,6 +160,9 @@ class MmFilemapAddToPageCache(Base): pfn = Column(Integer, nullable=False) ofs = Column(Integer, nullable=False) + # 1:1 relation with RawFtraceEntry. + raw_ftrace_entry = relationship("RawFtraceEntry", uselist=False) + @staticmethod def parse_dict(function_args, id = None): # dev 253:6 ino b2c7 page=00000000ec787cd9 pfn=1478539 ofs=4096 @@ -251,6 +259,8 @@ def parse_file(filename: str, *args, **kwargs) -> int: def parse_file_buf(filebuf, session, engine, raw_ftrace_entry_filter, limit=None) -> int: global _FLUSH_LIMIT count = 0 + # count and id are not equal, because count still increases for invalid lines. + id = 0 pending_entries = [] pending_sched_switch = [] @@ -305,9 +315,10 @@ def parse_file_buf(filebuf, session, engine, raw_ftrace_entry_filter, limit=None continue pending_entries.append(raw_ftrace_entry) + id = id + 1 if raw_ftrace_entry['function'] == 'sched_switch': - sched_switch = SchedSwitch.parse_dict(raw_ftrace_entry['function_args'], count) + sched_switch = SchedSwitch.parse_dict(raw_ftrace_entry['function_args'], id) if not sched_switch: print("WARNING: Failed to parse sched_switch: " + l) @@ -315,7 +326,7 @@ def parse_file_buf(filebuf, session, engine, raw_ftrace_entry_filter, limit=None pending_sched_switch.append(sched_switch) elif raw_ftrace_entry['function'] == 'sched_blocked_reason': - sbr = SchedBlockedReason.parse_dict(raw_ftrace_entry['function_args'], count) + sbr = SchedBlockedReason.parse_dict(raw_ftrace_entry['function_args'], id) if not sbr: print("WARNING: Failed to parse sched_blocked_reason: " + l) @@ -323,7 +334,8 @@ def parse_file_buf(filebuf, session, engine, raw_ftrace_entry_filter, limit=None pending_sched_blocked_reasons.append(sbr) elif raw_ftrace_entry['function'] == 'mm_filemap_add_to_page_cache': - d = MmFilemapAddToPageCache.parse_dict(raw_ftrace_entry['function_args'], count) + d = MmFilemapAddToPageCache.parse_dict(raw_ftrace_entry['function_args'], + id) if not d: print("WARNING: Failed to parse mm_filemap_add_to_page_cache: " + l) else: |