This is an archive of the discontinued LLVM Phabricator instance.

[trace] Show ideas for the main interfaces for new HTR
AbandonedPublic

Authored by wallace on Mar 31 2022, 8:07 PM.

Details

Summary

This diff tries to show the low level structures and the high level APIs for interacting with HTR (hierarchical trace representation). Most of the ideas are commented in the code. I want to get some feedback with this diff, but the actual implementation would be left for other diffs.

I describe in the code two storage strategies: in memory and on disk. Besides that, I mention two extensions: a time analyzer and a symbol index. I don't intent to implement them right away. I'm thinking about starting with the in memory one without adding many abstractions to the code, and also I'd implement first only the time analyzer. Later, we could continue implemeting the other parts mentioned in this diff, but at least I want to think about them now to make sure the basic design doesn't need a complete redesign once we want to add the other features.

I show at the end and snippet of a practical traversal of the HTR with timing information. Making sure that this part looks intuitive is important.

What I don't include here is the algorithm for creating the call tree. That's out of the scope of this diff. I want to focus first on the interfaces, as that's the part that should change the least. The algorithm can be implemented incrementally.

Diff Detail

Event Timeline

wallace created this revision.Mar 31 2022, 8:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 31 2022, 8:07 PM
wallace requested review of this revision.Mar 31 2022, 8:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 31 2022, 8:07 PM
wallace edited the summary of this revision. (Show Details)Mar 31 2022, 8:12 PM
davidca added inline comments.Apr 1 2022, 8:03 AM
lldb/include/lldb/Target/TraceHTR.h
73

Just like in the original HTR design, if you remove this abstraction, and store indices as indices in each layer, then you don't have to create separate versions for in memory and in disk, as the layers become very easily serializable.

118

This does not deduplicate blocks. If the same block appears multiple times (as it's common in loops), it will be stored multiple times, consuming more memory and making pattern detection and other post-processing more time consuming.

Note that this is the original motivation of the separation between BlockDefs and bids (the trace of block ids) in the original HTR doc.

clayborg added inline comments.Apr 6 2022, 1:44 PM
lldb/include/lldb/Target/TraceHTR.h
81

This seems like it should be stored as an optional value and if the optional value has no valid, it would need to be computed lazily?

83

Should this function be able to lazily compute itself? Right now you would need to parse the entire stream of instructions for a HTRInMemoryBlock contents to be valid? Is that what we want?

88

If you go with the GetChildrenCount() + GetChildAtIndex(...) workflow, then you can't lazily compute children. Do we want to go with an iterator kind of thing where you ask for the iterator for the first child and then ask for next until some ending?

90

I would avoid size_t as it is uint32_t on 32 bit systems and uint64_t on 64 bit systems. Probably just pick uint64_t?

113

Bounds check "index"?

187–188

Should we just make a TraceHTR base class that has all of the needed methods and store a single pointer here? Then TraceHTRInMemoryStorage and TraceHTROnDiskStore would subclass it?

191–192

Should we just make a HTRBlock base class that has all of the needed methods and store a single pointer here? Then HTRInMemoryBlock and HTROnDiskBlock would subclass it?

192
308

is the idea to somehow represent a lldb_private::Symbol from this index? What does a "symbol id" mean?

352–355

Yeah, I would make a base class here and just store one unique pointer here.

wallace abandoned this revision.May 12 2022, 2:41 PM