This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Introduce a tool to quickly generate projects with an arbitrary number of sources
AcceptedPublic

Authored by bulbazord on Jun 9 2023, 11:13 AM.

Details

Summary

The purpose of this tool is to be able to generate a project with an
arbitrary number of source files in a given programming language. I
believe this can be useful as it lets you benchmark a given LLDB change
for performance locally. For example, if you are changing the way LLDB
processes a specific debug info section, you may want to make sure that
you're not regressing performance (or if you're making the change for
performance, you want to ensure that it actually improves things). You
could use this tool to generate 10,000 (or more) source files and see
how quickly lldb processes the debug info of the resulting binary.

I understand that many folks will measure performance changes against
large projects, usually proprietary in nature. I believe this is quite a
valid way to measure performance changes and this tool isn't meant to
change that. I wanted to offer this tool primarily as an alternative
that gives the developer more control over the size and contents of the
project (which is not something you always have when working with
proprietary projects).

Currently this tool only supports C, C++, and Swift. The Swift portions will
only work on macOS right now and will not work with upstream lldb. There are
also multiple ways to build Swift projects, this just chooses one specific
approach. Future work could include adding an option to choose the structure of
the generated Swift project.

Diff Detail

Event Timeline

bulbazord created this revision.Jun 9 2023, 11:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 11:13 AM
bulbazord requested review of this revision.Jun 9 2023, 11:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 11:13 AM

That looks useful!

lldb/scripts/generate-project.py
176

Would """ multiline literals be more readable?

kastiglione added inline comments.Jun 9 2023, 12:42 PM
lldb/scripts/generate-project.py
119–127

minor, but I noticed some of these f-strings don't have an {} interpolation.

176

+1

kastiglione added inline comments.Jun 9 2023, 12:45 PM
lldb/scripts/generate-project.py
70
117
bulbazord updated this revision to Diff 530084.Jun 9 2023, 2:34 PM
  • Converted some things to use multiline string literals
  • Converted some f-strings into string literals when they didn't need interpolation
  • Applied black formatting
bulbazord marked 3 inline comments as done.Jun 9 2023, 2:35 PM
bulbazord added inline comments.
lldb/scripts/generate-project.py
176

I changed it, what do y'all think?

mib added inline comments.Jun 9 2023, 2:39 PM
lldb/scripts/generate-project.py
24

nit: Is it necessary to put it in a variable or could you have a multiline string in the write call ?

184–191

What about here ?

If you wanted to indent the long strings to the same level as the function's code you could use https://docs.python.org/3/library/textwrap.html#textwrap.dedent (but it's fine as is).

bulbazord updated this revision to Diff 530692.Jun 12 2023, 3:49 PM

Remove temp variables
More multiline string literals

bulbazord marked 4 inline comments as done.Jun 12 2023, 3:51 PM
mib accepted this revision.Jun 12 2023, 4:59 PM
This revision is now accepted and ready to land.Jun 12 2023, 4:59 PM
kastiglione added inline comments.Jun 12 2023, 5:48 PM
lldb/scripts/generate-project.py
21

os.path.join to be windows friendly?

kastiglione added inline comments.Jun 12 2023, 5:52 PM
lldb/scripts/generate-project.py
21

I just noticed the contents of the makefiles also have forward slashes, so I retract my comment.

If nobody else has any comments, I plan on landing this tomorrow.

clayborg added inline comments.Jun 15 2023, 4:02 PM
lldb/scripts/generate-project.py
21

I would vote to use os.path.join() instead of manually formatting strings

50

Add a "PP" to differentiate from c?

297–301

move into generate_sources(...)?