This is an archive of the discontinued LLVM Phabricator instance.

[trace][intelpt] Support system-wide tracing [18] - some more improvements
ClosedPublic

Authored by wallace on Jun 14 2022, 8:14 AM.

Details

Summary

This applies the changes requested for diff 12.

  • use DenseMap<ConstString, _> instead of std::unordered_map<ConstString, _>, which is more idiomatic and possibly performant.
  • deduplicate some code in Trace.cpp by using helper functions for fetching in maps
  • stop using size and offset when fetching binary data, because we in fact read the entire buffers all the time. If we ever need streaming, we can implement it then. Now, the size is used only to check that we are getting the correct amount of data. This is useful because in some cases determining the size doesn't involve fetching the actual data.
  • added back the x86_64 macro to the perf tests
  • added more documentation
  • simplified some file handling
  • fixed some comments

Diff Detail

Event Timeline

wallace created this revision.Jun 14 2022, 8:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2022, 8:14 AM
Herald added subscribers: jsji, pengfei. · View Herald Transcript
wallace requested review of this revision.Jun 14 2022, 8:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2022, 8:14 AM
jj10306 requested changes to this revision.Jun 15 2022, 9:53 AM

looks great overall, just a couple minor things.

lldb/source/Plugins/Process/Linux/Perf.cpp
205–217

can't this now be simplified to something like:

data_head %= data_size;
// Copy from the head to the end of the buffer.
output.insert(output.end(), data_head, data_size);
// Copy from the start of the buffer to the head.
output.insert(data.end(), data_start, data_head);

you will need to make the args to insert ptrs but the rough idea should be clear that you can unconditionally modulo the head no need to manually iterate any longer, just let insert handle that for you. you might need a check to see if the buffer is empty as well.

257–261

same comment as above

lldb/source/Plugins/Process/Linux/Perf.h
203–210

this is great, thanks for adding this

lldb/source/Target/Trace.cpp
45

nit: maybe put these in a separate namespace, up to you though.

67–75

nit: potentially better names on these?

This revision now requires changes to proceed.Jun 15 2022, 9:53 AM
wallace requested review of this revision.Jun 15 2022, 10:56 AM
lldb/source/Plugins/Process/Linux/Perf.cpp
205–217

yes! They will be fixed in https://reviews.llvm.org/D127881

257–261

+1

lldb/source/Target/Trace.cpp
45

they are static, so it's equivalent to having them in an anonymous namespace. LLVM prefers this approach over creating a specific namespace

67–75

I'm just renaming them to Lookup. The 2 is confusing

jj10306 accepted this revision.Jun 15 2022, 12:50 PM
This revision is now accepted and ready to land.Jun 15 2022, 12:50 PM