This is an archive of the discontinued LLVM Phabricator instance.

[lldb][test] Enable clang modules in API/tools/lldb-server (NFC)
Needs ReviewPublic

Authored by kastiglione on Aug 29 2022, 10:18 AM.

Details

Summary

While investigating slow tests, I noticed that TestLldbGdbServer.py (and
other tests) have slow compile times for the targets they build to test with.

This change speeds up TestLldbGdbServer.py by enabling clang modules for the
compilation. After seeing that compilation was slow, I ran with -ftime-trace
and saw that a significant amount of compilation time was spent parsing libc++
headers.

On my machine, this reduces TestLldbGdbServer.py from:

Before:

Ran 84 tests in 223.308s

After:

Ran 84 tests in 131.672s

Diff Detail

Event Timeline

kastiglione created this revision.Aug 29 2022, 10:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2022, 10:18 AM
kastiglione requested review of this revision.Aug 29 2022, 10:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2022, 10:18 AM

The test that's using iostream could be rewritten to use printf instead. It actually looks like most of those test can be compiled as C programs, which should speed this up even more.

kastiglione added a comment.EditedAug 29 2022, 11:04 AM

The file in question uses many other c++ headers: lldb/test/API/tools/lldb-server/main.cpp

Actually this file doesn't include iostream directly, maybe I was looking at another file, or maybe it's loaded indirectly?

% rg 'include\s+<[^.]+?>' test/API/tools/lldb-server/main.cpp
1:#include <atomic>
2:#include <cassert>
3:#include <chrono>
4:#include <cstdlib>
5:#include <cstring>
7:#include <future>
9:#include <memory>
10:#include <mutex>
21:#include <string>
22:#include <thread>
24:#include <vector>
kastiglione edited the summary of this revision. (Show Details)Aug 29 2022, 4:09 PM

I updated the description to remove the mention of iostream, since that's not the specific problem.

labath added a subscriber: labath.Aug 30 2022, 9:31 AM

I don't think this will work in general, as the modules feature requires all your dependencies to be modularized, and linux systems generally don't have that. You might be able to do a feature like "build no_debug_info tests with modules if the platform supports it" and then make sure darwin supports it.

Or you could split this test up into multiple files. Personally I think it would be super cool if we were able to compile this binary just once (like, putting the build action in the @static setUpClass(cls) method or something), as all of the tests in this file (and in this folder, actually) are going to be using the same one.

I don't think this will work in general, as the modules feature requires all your dependencies to be modularized, and linux systems generally don't have that. You might be able to do a feature like "build no_debug_info tests with modules if the platform supports it" and then make sure darwin supports it.

Yeah, that was my secondary concern, because that's why we don't run the gmodules variant there.

This comment was removed by kastiglione.