perf(functests): speedup — profrc pre-baking, pty-close shutdown, parallel port pools #103

Manually merged
jabber.developer2 merged 1 commits from feat/functest-speedup into master 2026-03-12 15:35:33 +00:00
Collaborator

Description:

Functional test speedup: ~7.6s → ~0.8s per test on local run (93 tests in 78s wall-clock across 4 parallel groups).

Changes

Pre-baked profrc — replace 16 interactive UI setup commands (/inpblock, /notify, /wrap, /roster, /occupants, /time) with a pre-written profrc containing [ui] and [notifications] sections. Saves ~1800ms/test.

pty-close shutdown — replace sleep(1) + blocking waitpid() with: close(pty fd) → SIGHUP → polling waitpid(WNOHANG) → SIGTERM/SIGKILL fallback. Saves ~4900ms/test.

Remove stabber sleepsusleep(100ms) after stbbr_start() and stbbr_stop() are unnecessary: bind()+listen() complete synchronously before return; pthread_join() guarantees socket release. Saves ~200ms/test.

Parallel port poolsPORTS_PER_GROUP=50 isolated port ranges (group 1: 5230–5279, group 2: 5280–5329, etc.) for safe parallel execution without port conflicts.

Dependencies

Requires stabber with accept-loop hang fix (devs/stabber@5bb776c) — without it stbbr_stop() can hang when sleeps are removed.

**Description:** Functional test speedup: ~7.6s → ~0.8s per test on local run (93 tests in 78s wall-clock across 4 parallel groups). ### Changes **Pre-baked profrc** — replace 16 interactive UI setup commands (`/inpblock`, `/notify`, `/wrap`, `/roster`, `/occupants`, `/time`) with a pre-written profrc containing `[ui]` and `[notifications]` sections. Saves ~1800ms/test. **pty-close shutdown** — replace `sleep(1)` + blocking `waitpid()` with: `close(pty fd)` → SIGHUP → polling `waitpid(WNOHANG)` → SIGTERM/SIGKILL fallback. Saves ~4900ms/test. **Remove stabber sleeps** — `usleep(100ms)` after `stbbr_start()` and `stbbr_stop()` are unnecessary: `bind()+listen()` complete synchronously before return; `pthread_join()` guarantees socket release. Saves ~200ms/test. **Parallel port pools** — `PORTS_PER_GROUP=50` isolated port ranges (group 1: 5230–5279, group 2: 5280–5329, etc.) for safe parallel execution without port conflicts. ### Dependencies Requires stabber with accept-loop hang fix (devs/stabber@5bb776c) — without it `stbbr_stop()` can hang when sleeps are removed.
jabber.developer2 added 1 commit 2026-03-12 10:10:57 +00:00
perf(functests): speedup — profrc pre-baking, pty-close shutdown, parallel port pools
Some checks failed
CI Code / Check spelling (pull_request) Successful in 19s
CI Code / Check coding style (pull_request) Successful in 33s
CI Code / Code Coverage (pull_request) Successful in 3m1s
CI Code / Linux (debian) (pull_request) Failing after 4m28s
CI Code / Linux (ubuntu) (pull_request) Failing after 4m28s
CI Code / Linux (arch) (pull_request) Successful in 10m13s
ee306c18f9
Replace 16 interactive UI setup commands with pre-written profrc file
containing [ui] and [notifications] sections (~1800ms saved per test).

Replace sleep(1) + blocking waitpid with close(pty fd) → SIGHUP →
polling waitpid(WNOHANG) → SIGTERM/SIGKILL fallback chain (~4900ms
saved per test).

Remove post-stbbr_start() and post-stbbr_stop() sleeps — bind+listen
completes synchronously before stbbr_start() returns, and
pthread_join() in stbbr_stop() guarantees socket cleanup (~200ms saved).

Add PORTS_PER_GROUP=50 isolated port ranges per test group to enable
safe parallel execution of 4 groups without port conflicts.
jabber.developer2 force-pushed feat/functest-speedup from ee306c18f9 to ce94d89250 2026-03-12 10:27:31 +00:00 Compare
jabber.developer requested changes 2026-03-12 14:15:30 +00:00
Dismissed
jabber.developer left a comment
Owner

Generally good, but a few fixes later it's going to be much better

Generally good, but a few fixes later it's going to be much better
@@ -248,4 +249,1 @@
/* Calculate port base: each build uses a different range of TEST_GROUPS ports.
* Build 0 (local/default): 5230-5233, Full: 5230-5233, Minimal: 5234-5237, etc.
* Build 0 and Full share the same range because build 0 is for local runs or sequential run (no parallel builds),

It was a useful explanation, I do not see a good reason to remove it.

It was a useful explanation, I do not see a good reason to remove it.
Author
Collaborator

Restored

Restored
jabber.developer marked this conversation as resolved
@@ -315,38 +317,42 @@ init_prof_test(void **state)
_create_chatlogs_dir();
_create_logs_dir();
/* Pre-write profrc with all UI settings that were previously set via

Again comment reflects the change rather then adding the context to the code. It would make more sense to write why we setup this specific value prior to firing the tests (e.g., to ensure consistent output)

Again comment reflects the change rather then adding the context to the code. It would make more sense to write why we setup this specific value prior to firing the tests (e.g., to ensure consistent output)
Author
Collaborator

Corrected

Corrected
jabber.developer marked this conversation as resolved
@@ -362,1 +369,4 @@
fd = 0;
/* Poll for exit — typically completes in <100ms */
int exited = 0;
for (int i = 0; i < 100; i++) { /* 100 × 50ms = 5s max */

100 is a magic number; it should be defined as a constant where explanation could be provided

100 is a magic number; it should be defined as a constant where explanation could be provided
Author
Collaborator

Corrected

Corrected

Not fixed actually (usleep(100000);)

Not fixed actually (`usleep(100000);`)
jabber.developer marked this conversation as resolved
@@ -363,0 +374,4 @@
exited = 1;
break;
}
usleep(50000); /* 50ms */

here and later magic numbers

here and later magic numbers
Author
Collaborator

Corrected

Corrected
jabber.developer marked this conversation as resolved
@@ -378,3 +401,1 @@
* See: https://git.jabber.space/devs/stabber/issues/3
*/
usleep(100000); // 100ms
/* No sleep needed: stbbr_stop() calls pthread_join() which blocks until

The comment again reflects the change, though it also provides the context. However, I am not sure if it needs to stay. This context could be moved to the git commit message, which could later be checked via blame by anyone who plans to change this part.

The comment again reflects the change, though it also provides the context. However, I am not sure if it needs to stay. This context could be moved to the git commit message, which could later be checked via blame by anyone who plans to change this part.
Author
Collaborator

Corrected

Corrected
jabber.developer marked this conversation as resolved
jabber.developer2 force-pushed feat/functest-speedup from ce94d89250 to d98f270cb6 2026-03-12 14:36:18 +00:00 Compare
jabber.developer2 force-pushed feat/functest-speedup from d98f270cb6 to ec586105b4 2026-03-12 14:44:40 +00:00 Compare
jabber.developer2 force-pushed feat/functest-speedup from ec586105b4 to 24f7141c98 2026-03-12 15:06:33 +00:00 Compare
jabber.developer approved these changes 2026-03-12 15:14:28 +00:00
jabber.developer left a comment
Owner

LGTM

LGTM
jabber.developer2 force-pushed feat/functest-speedup from 24f7141c98 to f84ed1bf6a 2026-03-12 15:20:39 +00:00 Compare
jabber.developer reviewed 2026-03-12 15:33:52 +00:00
@@ -493,3 +542,3 @@
prof_input("password");
expect_timeout = 60;
expect_timeout = EXPECT_TIMEOUT_CONNECT;

it feels like it could substituted with prof_timeout_reset to deduplicate code; it's out of scope though.

it feels like it could substituted with `prof_timeout_reset` to deduplicate code; it's out of scope though.
jabber.developer2 manually merged commit f84ed1bf6a into master 2026-03-12 15:35:33 +00:00
Sign in to join this conversation.
No description provided.