Repository navigation
CI: harness and sharding speedups - #9793
Open
daywalker90 wants to merge 11 commits into
Open
daywalker90 wants to merge 11 commits into
daywalker90 wants to merge 11 commits into
Conversation
nGoline
requested changes
Dec 1, 2026
nGoline
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for splitting this out. The sharding itself looks right: I ran the --balanced-group hook against master's 1345 tests for 6, 16 and 3 shards and got an exact partition, no duplicates, nothing missing. The one change I'd block on is in NodeFactory: under valgrind, plugins are now traced only for the first node a test creates, which drops real coverage (inline). The rest are smaller.
daywalker90
force-pushed
the
ci/harness-and-sharding-speedups
branch
from
December 1, 2026 15:45
dbfcaf4 to
b86d0a2
Compare
nGoline
approved these changes
Dec 1, 2026
During dev-memleak teardown, scan_for_pointers() tests every pointer-sized word in every tal allocation against memtable via memleak_ptr(). Previously each word ran siphash24() and probed the htable even for NULLs, small integers, and ASCII data, taking ~1.5s per node on debug builds. Use htable's existing common_mask/common_bits invariant to reject non-matching words before hashing, and replace siphash24 with a fast invertible pointer mix for this local-only dev table. Identical leak detection, ~20x faster dev-memleak.
The autouse jsonschemas fixture was function-scoped, reloading and compiling all 164 doc/schemas/*.json validators on every test (~150ms each). Similarly, checkPluginJSON() reloaded all 39 notification and hook schemas for every node in teardown (~30ms per node). Make jsonschemas session-scoped and lru_cache _extra_validator() and _plugin_schemas(). No test mutates the loaded schema dicts, and the exact same request, response, hook, and notification validations run.
NodeFactory.killall() previously checked dev_memleak and stopped each node sequentially, multiplying teardown latency by the number of nodes (especially noticeable on 5-14 node tests and under Valgrind). Run dev_memleak across all nodes in parallel via self.executor, then stop all nodes in parallel, preserving deterministic error reporting. Also cache lightningd --version per executable path in LightningD instead of spawning a subprocess for every node created.
Cheroot's Server defaults expiration_interval to 0.5s, causing each BitcoinRpcProxy.stop() to block for up to 500ms. BitcoinD.stop() also stopped all proxies sequentially before stopping bitcoind, adding ~0.5s per node to every test teardown (~2.5s on a 6-node test). Additionally, BitcoinRpcProxy.start() probed TCP connect to check readiness, which succeeds as soon as cheroot's prepare() calls listen(), before prepare() finishes starting worker threads and sets server.ready = True. Fast start=False tests could then enter teardown and call server.stop() while server.ready was still False, causing cheroot's stop() to return as a no-op before prepare() set ready = True and entered serve() forever, deadlocking proxy_thread.join(). Lower expiration_interval to 0.05s, wait for self.server.ready in start(), bound/retry proxy_thread.join() in stop(), and stop all proxies concurrently with bitcoind shutdown.
…_for_logs wait_for() previously started at 0.25s and backed off up to 5s, while TailableProc.wait_for_logs() polled at a fixed 0.25s and wait_for_route() polled at 1s. Across thousands of sync_blockheight, node startup, and log waits, this added substantial idle sleep latency. Start wait_for() at 0.05s (capped at 1s, or 2s on SLOW_MACHINE), start wait_for_logs() at 0.02s backing off to 0.25s, and implement wait_for_route() using wait_for().
… by default Every lightningd startup was spawning all subdaemons with `--version` and allocating/reading/CRC32C-hashing ~1 GB of debug plugin binaries, nearly doubling startup time (~276ms -> ~145ms locally, and more under ASan/UBSan). Enable both dev flags unconditionally in `LightningNode`, intentionally trading away repeated per-node startup coverage of the subdaemon version check (`lightningd/lightningd.c`) and plugin binary checksum (`lightningd/plugin.c`) outside Valgrind. Both paths remain covered by dedicated tests (`test_version_reexec`, which now clears `dev-no-version-checks`, and `test_restart_on_update`, which already clears `dev-no-plugin-checksum`).
- Open PostgresDb's psycopg2 connection lazily on first Python query/exec instead of eagerly per node (most nodes never query Postgres from Python). - Fix the missing f-string in PostgresDb.stop(), close the client connection, and delegate database removal to PostgresDbProvider.drop_db(). - Guard CREATE/DROP DATABASE with a lock so parallel NodeFactory.get_nodes() calls are thread-safe, poll readiness every 50ms instead of 500ms, disable unnecessary durability settings for ephemeral test clusters, and add ScopedDbProvider for per-test database cleanup.
Reuse one PostgreSQL cluster per pytest worker session instead of running initdb and starting/stopping a new postgres instance for every single test. NodeFactory wraps the session provider in ScopedDbProvider so every database created during a test (including bookkeeper accounts DBs) is dropped during fixture teardown once all nodes have stopped.
- Add `*cln-lsps-client*` and `*cln-lsps-service*` to Valgrind's `--trace-children-skip` pattern, matching every other Rust plugin (`cln-grpc`, `clnrest`, `wss-proxy`, `cln-bip353`, `cln-currencyrate`). - Pass `--vgdb=no` to Valgrind to avoid per-process gdbserver FIFO/shm setup across thousands of subdaemon and plugin spawns without changing Memcheck error detection. - Avoid O(N^2) `getinfo()`/`listnodes(id)` RPC polling at the end of `NodeFactory.join_nodes()`.
Random sharding (`--test-group-random-seed=42`) created wide shard variance across Valgrind and first-integration shards. Add a zero-dependency `--balanced-group=G/N` option in `tests/conftest.py` that partitions collected tests via deterministic Longest Processing Time first (LPT) greedy bin-packing over `tests/test_durations.json` (and `tests/test_durations_valgrind.json` when `VALGRIND=1`, since CPU-heavy tests scale much more steeply than sleep-heavy tests under Valgrind): - Share `_skip_reason()` between `pytest_runtest_setup()` and LPT weighting so skipped `slow_test` / v2-only items cannot drift. - Preserve original collection order within each shard so heavy multi-node tests do not all launch simultaneously at t=0. - New tests not yet in the durations JSON fall back to a default weight and deterministically land in exactly one shard. - Add `tools/update-test-durations.py` to regenerate the duration tables from CI `report.xml` JUnit artifacts when shard balance drifts.
…n jobs - Add `TEST_ONLY=1` mode to `.github/scripts/setup.sh` so test-only jobs unpacking prebuilt artifacts skip heavy build/lint toolchains while keeping all runtime libraries and test tools; remove the unused `microsoft-prod` apt repo (which transiently 403s) and enable apt retries. - Skip redundant `git submodule sync && git submodule update` in the 6 pytest-only jobs (40 runners total) that never run `make` or touch `external/` C submodules, eliminating ~200 simultaneous GitHub clones that can trigger GitHub 403 rate limiting. - Switch `first-integration` (6), `integration-valgrind` (16), and `integration-sanitizers` (6) to `--balanced-group=G/N`. - Shard `full-integration` postgres (3) and liquid (3) plus `min-btc-support` (2). - Start `integration-valgrind` and `min-btc-support` directly after `compile`.
daywalker90
force-pushed
the
ci/harness-and-sharding-speedups
branch
from
December 1, 2026 18:02
b86d0a2 to
8d8466a
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog-None