[Lldb-commits] [lldb] [lldb] Split TestGdbRemoteFork test to avoid timeout (PR #129614)

David Peixotto via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 7 10:55:08 PST 2025


dmpots wrote:

I looked into why this test (and TestGdbRemoteFork.py) is so slow. Turns out its nothing related to lldb itself, but the build step that occurs as part of the test.

These tests methods pretty much  all call to `build()` (directly or indirectly) 
https://github.com/llvm/llvm-project/blob/ca1833b91e45595a3728e90b3714566588c8abae/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py#L59

to build the test lldb-server
https://github.com/llvm/llvm-project/blob/main/lldb/test/API/tools/lldb-server/main.cpp

And it takes about 20s to compile this file with a debug build! So each test is running for at least 20s. The actual test part (after the build) seems to usually be quite fast (< 1s).

The tests use the just-built clang to compile the file. Looking at the output from `-ftime-passes` most of this time is in the clang front end.

```
  Total Execution Time: 20.7652 seconds (20.7634 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
  18.0725 ( 88.1%)   0.1921 ( 73.6%)  18.2646 ( 88.0%)  18.2628 ( 88.0%)  Front end
   1.1838 (  5.8%)   0.0538 ( 20.6%)   1.2376 (  6.0%)   1.2377 (  6.0%)  Machine code generation
   1.1807 (  5.8%)   0.0141 (  5.4%)   1.1948 (  5.8%)   1.1946 (  5.8%)  LLVM IR generation
   0.0671 (  0.3%)   0.0010 (  0.4%)   0.0682 (  0.3%)   0.0682 (  0.3%)  Optimizer
  20.5041 (100.0%)   0.2611 (100.0%)  20.7652 (100.0%)  20.7634 (100.0%)  Total
```

Looking at the build() implementation, it looks like it builds a separate binary for each `test_` method even though those seem to the same binary.

`build()` will call `getBuildDirBasename()` to get the output directory
https://github.com/llvm/llvm-project/blob/96f369791d6c146ccadb03e7f9d6b1be37990425/lldb/packages/Python/lldbsuite/test/lldbtest.py#L1498

which is defined so that the test to include name as part of the path
https://github.com/llvm/llvm-project/blob/96f369791d6c146ccadb03e7f9d6b1be37990425/lldb/packages/Python/lldbsuite/test/lldbtest.py#L726C9-L726C69


Any suggestions on how to improve this? It seems like we could maybe share the built executable amongst all tests  in the file, but the test framework does put them into separate per-test locations.



https://github.com/llvm/llvm-project/pull/129614


More information about the lldb-commits mailing list