-
Notifications
You must be signed in to change notification settings - Fork 33
systrace parsing new edition #249
Conversation
|
If we add a specific parser class for |
|
I don't grok the existing parsing code but this seems good to my slightly inexpert eyes. My only concern (aside from the little comments on the |
|
Brendan you closed this PR, hope that wasn't intentional? ;) You are right this will break that. It could be easily fixed though by making sure tracing mark write class is used only when nothing else matched. I will work on fixing that. I will also add better commit message for explaining the parsing. |
Yep, accident, sorry! |
This is needed so that we're not dependent anymore on making sure data starts at something with '=' and will allow to parse custom systrace tracing_mark_write events which don't have an '=' in them. The new regex will also work for lines that do already have an '=' and doesn't change their behavior. The last line of the new regex in this patch works like this: r"(?P<timestamp>[0-9]+\.[0-9]+): (\w+:\s+)+(?P<data>.+)" We use skip over '<string>:<whitespace> ' and the next thing we find is considered the start of the data. This works well to find the start of a line for existing traces and is needed for systraces which don't have '='. Signed-off-by: Joel Fernandes <[email protected]>
In preparation of being able to parse systrace, split out data string processing into separate function so it can be overridden by sub classes. Signed-off-by: Joel Fernandes <[email protected]>
sinkap
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor comments. Otherwise LGTM
| trace_class.finalize_object() | ||
|
|
||
| def generate_data_dict(self): | ||
| return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should raise a NotImplemented exception if this is called. Or we can just remove this method no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we remove it, it will break code that calls it (since not all tracers are expected to implement it). Also not implementing it is not an exception but the normal fall back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we should have this raise the exception and we should catch the exception and then implement the fallback. So that it can be more explicit
| @@ -0,0 +1,33 @@ | |||
| # Copyright 2017 ARM Limited, Google and contributors | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a module docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
| from trappy.base import Base | ||
| from trappy.dynamic import register_ftrace_parser | ||
|
|
||
| class TracingMarkWrite(Base): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a docstring for the class. I know we have not been careful about doing this. I will probably need to backfill.
| from trappy.ftrace import GenericFTrace | ||
| import re | ||
|
|
||
| class drop_before_trace(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have been naming the classes as DropBeforeTrace. Also I am not sure what the name conveys. I will change that in a follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
trappy/systrace.py
Outdated
|
|
||
| return data_dict | ||
|
|
||
| SYSTRACE_EVENT = re.compile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this to the top
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
trappy/base.py
Outdated
| """ | ||
| def __init__(self, parse_raw=False): | ||
| def __init__(self, parse_raw=False, is_backup=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add to the documentation what is_backup actually means? Let's call it is_fallback as discussed.
Create tracing_mark_write as an event and treat it like such. It overrides data string processing since it cannot use 'key=value' parsing. Instead it relies on the tracer to provide one (such as systrace has custom trace format from userspace events). If tracer cannot provide one, then it just returns a default dictionary with key 'string' and value as the string in the event. Signed-off-by: Joel Fernandes <[email protected]>
Here we provide custom data string parsing for Android userspace events. Borrowed the regex and parsing logic from Patrick's patch. Co-developed-by: Patrick Bellasi <[email protected]> Signed-off-by: Joel Fernandes <[email protected]>
…_write Certain fake events can be injected using tracing_mark_write and should be classified into their own event classes than tracing_mark_write. One way to handle this is to use tracing_mark_write only as a backup. For this reason lets introduced the concept of backup event classes and classify TracingMarkWrite as that. This case normally doesn't happen because dynamic events are inserted into the beginning of the event list from what I've seen. Since tracing_mark_write is a built-in event, and not dynamic, its always at after and so is less preferred. However we should protect for the future case where there might be a built-in which happens to be after TrackingMarkWrite class in the list, so lets handle it now. Signed-off-by: Joel Fernandes <[email protected]>
Signed-off-by: Joel Fernandes <[email protected]>
|
Okay. I am merging this one. Thanks everyone! |
|
Merged right? |
Update trappy and fix cpu_idle
Hi @derkling ,
I went ahead and re-wrote #243. This is very fresh so I am just posting it early for any comments. This approach is more cleaner and also doesn't have issues with #243. It also doesn't require dropping custom strings written by tracing_mark_write that systrace doesn't recognize . I didn't add your test case but I ran some scripts to see it working and existing nosetests are passing. I would appreciate if you can integrate your test case from #243 to work with this PR and feel free to repost this PR with that. We can also close that old PR and work with this one. I borrowed your regex from the systrace format patch and given you credit in the relevant patch, thanks. CC @bjackman