morningman opened a new issue, #71314: URL: https://github.com/apache/doris/issues/71314
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues. ### Description `run-be-ut.sh` builds one `doris_be_test` binary from about 1,400 test files (no unity build, no PCH for tests) and `--run` runs all of its ~17,500 tests in a single process, one after another. Measured with `run-be-ut.sh -j 6` (ASAN, 18-core Apple M5 Pro, 48 GB): | Scenario | Time | |---|---| | Cold build of the tests (test files take ~70% of the summed per-file compile time) | 1613.7 s | | No-op rebuild | 8.0 s | | Rebuild after changing one test file | 42.2 s | | Rebuild after changing one be/src leaf file | 47.2 s | | Rebuild after changing `common/config.h` | 1442.7 s | | Full run, one process (`--run`) | 2661.1 s | | One small suite (`--filter=CodingTest.*`), build check included | 12.0 s | Running everything in one process also hides problems. Tests depend on what earlier tests left behind (config values, a `FileCacheFactory` or searcher cache installed in `ExecEnv`, signal dispositions, process-wide caches, shared directories in the source tree, fixed ports), so many tests pass only in the order the binary happens to run them. Some product bugs only show up on another platform or in another order. The goal is a shorter edit-build-test loop and a shorter full run, with every test independent of what ran before it, and every change measured against the numbers above under the same protocol. ### Solution The work is done on one branch, measured, and then proposed in reviewable PRs (listed below as they open). The phases: **P0. Measurement baseline (done).** The scenarios above, with an environment gate for the machine, and `run-be-ut.sh --compile-bench`, which reports the compile time of each file of a cold build. **P1. Parallel runs and test isolation (done on the branch; being split into PRs).** - `run-be-ut.sh --run -j N` runs the tests in N processes: suites in batches, longest first from the recorded timings, admitted by memory, each worker in its own cwd, `DORIS_HOME` and `TMPDIR`; a crash or a hang is pinned to its test and the rest of the batch resumes; the gtest XML files are merged. `-j 1`, `--gdb`, coverage and `GTEST_REPEAT` still use one process. CI's test stage, which starts `doris_be_test` itself, is not affected. - A config framework for tests (`testutil/test_config.h`): every test starts from the same config; a suite or test declares the values it needs (`DORIS_TEST_SUITE_CONFIG`, `DORIS_TEST_CONFIG`), changes in the middle of a test go through `test::set_config()`, and the framework sets everything back after each test and fails a test that leaves a change no declaration covers. It replaces the hand-written save-and-restore code in about 270 test files. - Tests that depended on the order or on process-wide state, timing-sensitive tests, and tests that failed on macOS / libc++ are fixed at the cause. - Product bugs that these runs exposed are fixed, each with a test, for example: a local exchange reading its exchanger through a `unique_ptr` being destroyed; out-of-bounds reads in `group_array` and `from_iso8601_date`; `LoadStreamMgr` reading its stream count without its lock; `EvHttpServer::stop()` missing a worker that has not entered its event loop; the cooldown meta writers freeing shared state before joining their threads and retrying a failed write in a tight loop; file cache background threads waiting out a whole interval on stop; an FD cache that never shrinks after its capacity is lowered. - Result on the same machine and protocol: the full run takes 390.6 s with `-j 6` instead of 2661.1 s in one process (6.8x), and every test passes, also in shuffled order (the one-process baseline had 23 to 26 failures on macOS). **P2. Faster builds (next).** - [ ] Compile profile of a cold build: be/src against be/test, the slowest files, front end against template instantiation against code generation, link and debug info, the tail of the critical path. - [ ] Link stage: measure linking, `dsymutil` and `strip`; skip the last two locally while keeping ASAN stacks symbolized; try ld64.lld. - [ ] Per-invocation overhead: skip the submodule update and the CMake configure when nothing they depend on changed. - [ ] A precompiled header for `doris_be_test`, and unity builds for be/test (by directory, small batches, with the name clashes resolved). - [ ] Lighter test headers, and the giant test files on the critical path. - [ ] Study of structural options: linking be/src as a shared library, or splitting the test binary. **P3. Faster runs (after P1).** - [ ] Run profile: long-pole suites, sleep-bound tests, process start cost, idle worker tails. - [ ] Schedule long-pole suites by test instead of by suite, or split them. - [ ] Replace fixed sleeps and polling with condition waits or injected clocks, and shrink data sizes where coverage stays the same. - [ ] Cheaper process start (lazy initialization in `main()`; death tests re-execute the binary). - [ ] Memory per worker and ASAN options, without weakening what ASAN detects. **P4. Wrap-up.** - [ ] Verify on Linux (CI builds with clang, ASAN and PCH off) and measure the key numbers there. - [ ] Before-and-after comparison of all scenarios under the same protocol. - [ ] Optionally, run CI's BE unit test stage in parallel too. ### PRs - Reference branch with everything in P1, not for merging: (draft PR to be linked) - Order of the split PRs: product code fixes in be/src first, then the test frameworks (runner, config framework), then the test changes; the switch that makes undeclared config changes fail the run goes last, after every test is migrated. ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
