morningman opened a new pull request, #71315:
URL: https://github.com/apache/doris/pull/71315

   ### Background
   
   The BE unit tests are one binary, `doris_be_test`, that `run-be-ut.sh` 
builds from about 1,400 test files. `run-be-ut.sh --run` starts it once, and 
its ~17,500 tests run one after another in that process; CI builds the binary 
with `run-be-ut.sh` and then starts `doris_be_test` itself. All tests share the 
process's state: config values, components installed in `ExecEnv` (file cache 
factory, searcher caches, `TmpFileDirs`), process-wide caches and signal 
dispositions.
   
   ### What problem does this PR solve?
   
   Issue Number: #71314
   Related PR: None
   PR Type: Performance
   
   Problem Summary:
   
   A full local run takes 44 minutes on a machine with 18 cores, and it passes 
only in the order the binary happens to use: tests rely on state that earlier 
tests leave behind, and on macOS 23 to 26 tests failed. This branch runs the 
tests in N processes (`run-be-ut.sh --run -j N`), gives tests a config 
framework so that every test starts from the same config, fixes the tests that 
depended on the order or on process state, and fixes the product bugs that 
these runs exposed. With `-j 6` the full run takes 390.6 s instead of 2661.1 s 
(6.8x), and every test passes, also in shuffled order. This PR shows the whole 
change and its combined effect; it will not be merged, and it is being split 
into reviewable PRs tracked in #71314.
   
   ### Details
   
   - **Change map:** 135 commits, +8709 -4639 in 347 files. Production code 
+333 -62 (26 files): product bug fixes, each with a test, and a few test hooks. 
Tests +6278 -4536 (311 files): the config framework for tests 
(`testutil/test_config.{h,cpp}` and its self-tests, about 1,500 lines), about 
270 test files moved from hand-written save-and-restore to declarations, and 
the isolation and portability fixes. Build and CI +2097 -40 (9 files): the 
parallel runner (`build-support/run-be-ut-parallel.py`, 1,117 lines, with a 
self-test) and `run-be-ut.sh --compile-bench`. One submodule pointer: 
`contrib/apache-orc` moves d88650dcd09..f346be42a52 
(apache/doris-thirdparty#446, an ORC test that no longer calls `setenv("TZ")`).
   - **Why it was slow:** one process runs every test serially, so a full run 
uses one core's worth of test time; the 44 tests of 10 s or more alone take 36% 
of it. The longest suite, `BlockFileCacheTest`, took 610 s, mostly waiting: 
each time a cache stopped, its TTL manager's threads could wait up to 180 s 
before they noticed.
   - **Optimization:** the runner runs suites in batches of processes, longest 
first by the timings it recorded, admits processes by their recorded memory, 
gives each worker its own cwd, `DORIS_HOME` and `TMPDIR`, pins a crash or a 
hang to its test and resumes the rest of the batch, and merges the gtest XML 
files. Running tests in other processes and other orders needed the tests to 
stop depending on each other, which is most of the diff.
   - **Results:** measured with `run-be-ut.sh`, ASAN, Apple M5 Pro (18 cores, 
48 GB), before the rebase onto the current master:
   
   | Full run | Before (one process) | After |
   |---|---|---|
   | `-j 6` | 2661.1 s (median of 2) | 390.6 s (median of 3, spread 4.1%) |
   | `-j 4` / `-j 8` (one run each) | | 538.6 s / 383.4 s |
   | Failing tests on macOS | 23 and 26 | 0 |
   | Shuffled order (`GTEST_SHUFFLE=1`, seed 48256) | | 0 failing |
   
   - **Applicability and cost:** it helps full and multi-suite local runs. A 
filter that names one suite, `-j 1`, `--gdb`, coverage and `GTEST_REPEAT` keep 
one process. CI's test stage starts `doris_be_test` itself, so it is not 
affected. N processes need more memory: the runner admits them against 80% of 
the available memory (peak 15 to 17 GB at `-j 6` here). Build times do not 
change; they are the next phase in #71314.
   - **Behavior change:** the branch also changes the default of 
`ca_cert_file_paths` (adds `/etc/ssl/cert.pem`), rejects a negative 
`file_cache_max_file_reader_cache_size`, retries a failed cooldown meta write 
once per cooldown round instead of at once, and makes `run-be-ut.sh --run` use 
`-j` processes (default: cores / 5 + 1).
   
   ### Testing
   
   - After the rebase onto master f2c8f96b22b, macOS 26.5, clang 22.1.8, ASAN, 
run locally: `./run-be-ut.sh --run -j 6` ran 17865 tests: 17785 passed, 78 
skipped, 2 failed, in 482.3 s (73 processes, peak 16.5 GB); with 
`GTEST_SHUFFLE=1 GTEST_RANDOM_SEED=48256` the same counts in 525.1 s. No crash, 
hang or undeclared config change in either run. These runs are checks, not 
timing samples: the suites that master added have no recorded timing or memory 
yet, so they run one per process.
   - The 2 failures are 
`VGeoFunctionsTest.GeographyRejectsRoundedNonpointPolygonSideConversion` and 
`VGeoFunctionsTest.GeographyStabilizesShellBeforeAdmittingHole`, which #69032 
added on 12-01. They fail the same way when that suite runs alone (`--run -j 1 
--filter='VGeoFunctionsTest.*'`), and this branch does not touch the geo 
functions; they are not investigated yet.
   - Before the rebase (on master d43bbb7472d), the same two runs passed every 
test: 17511 tests, 17433 passed, 78 skipped.
   - `build-support/tests/test-run-be-ut-parallel.sh` (the runner's self-test 
against a fake test binary): all checks passed.
   
   ### Notes for Reviewers
   
   - Not for merging: review the split PRs as they open (listed in #71314). 
Their order: product code fixes in be/src first, then the runner and the config 
framework, then the test changes; the switch that fails a test on an undeclared 
config change goes last.
   - The work was done on macOS; the split PRs are verified on Linux as well.
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details)
   - Does this need documentation: Yes (the BE config docs of 
`ca_cert_file_paths` and `file_cache_max_file_reader_cache_size`, with the 
split PRs)
   - Pre-submission status: Not ready: a reference PR that will not be merged; 
it is split into reviewable PRs (#71314)
   
   ### AI Disclosure
   
   - Tool: Claude Code (Claude Opus 5.5)
   - Generated: the code, the tests and this description
   - Human review: not stated
   


-- 
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]

Reply via email to