Skip to content

test(build): shard test_thread_local_destructors over four tests - #26388

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
zedekvdb:test/shard-thread-local-destructors
Nov 23, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
zedekvdb:test/shard-thread-local-destructors

Conversation

@zedekvdb

Copy link
Copy Markdown
Contributor

What

test_thread_local_destructors runs nm over every test executable in one CTest test, 100 files per call, one batch after another. It takes 30.8 s on the Windows CI runner (Windows job of run 45139610913, main 151a77c837), over the 30 s that CONTRIBUTING.md allows, and it grows with every new test executable. Nearly all of the time is the nm phase: on a full build of d32e214029 with 3365 test executables, nm took 21 s and the objdump phase found no file to disassemble.

ThreadLocalDestructors.cmake now takes optional SHARD and SHARDS values. With them it sorts the matching files and checks every SHARDS-th one starting at SHARD, so the shards together check each file once; an out-of-range SHARD fails. Without them it checks all files, as prx_thread_local_destructors and thread_local_destructors_unusable_nm still do. The registration follows rebase_verify (#25461): the test keeps its name for shard 0, and test_thread_local_destructors_shard_1 to _3 check the other files, each with the same 300 s timeout.

tools/pr_overlap.py --branch could not compare 13 open pull requests that conflict with main and change core/libs/CMakeLists.txt. I compared their diffs by hand: none changes a thread_local test registration, and no open pull request changes ThreadLocalDestructors.cmake.

Tested

Windows 11 Pro 10.0.26300, i7-8750H laptop, WinLibs GCC 15.2.0 r7, full build of main d32e214029 with this change applied.

  • The script alone on the 3365 test executables: unsharded 21.1 s; shards 0 to 3 took 11.4, 8.5, 7.2 and 4.6 s and checked 842, 841, 841 and 841 files, 3365 together.
  • SHARD=4 SHARDS=4 fails with SHARD must be from 0 to SHARDS - 1. The unsharded *.prx check still checks all 413 modules.
  • ctest -N -R thread_local_destructors lists the four tests next to prx_thread_local_destructors and thread_local_destructors_unusable_nm. ctest -R thread_local_destructors -j 4: all 6 pass; the shards took 13.1 to 19.5 s while running next to each other and to prx_thread_local_destructors.
  • python tools/check_conventions.py --base origin/main passes. Not run on the CI runners; Linux and macOS do not register these tests.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

test_thread_local_destructors runs nm over every test executable in one
test, batch after batch, and takes 30.8 s on the Windows CI runner; it
grows with every new test. ThreadLocalDestructors.cmake now takes
optional SHARD and SHARDS values and checks every SHARDS-th file of the
sorted list starting at SHARD. The test keeps its name for shard 0, and
test_thread_local_destructors_shard_1 to _3 check the other files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is inside if(MINGW) in core/libs/CMakeLists.txt, so test_thread_local_destructors and its shards only exist on the MinGW/Windows build — ctest -N -R thread_local_destructors shows 0 tests on this Linux box, so I could not execute it here.

By inspection the sharding is sound: it round-robins the globbed *.exe modules by sorted index (index % SHARDS), guards bad SHARD/SHARDS with FATAL_ERROR, returns cleanly on an empty shard, and keeps the shard-0 name as test_thread_local_destructors so existing references still resolve while shards 1–3 get _shard_N names. The one thing to confirm is that CI actually runs all four shards on Windows; if it only runs the base name, shards 1–3 would be dead weight. Worth a Windows CI check before merge.

@oneandonlydean
oneandonlydean merged commit c3e0f38 into boykopovar:main Nov 23, 2026
13 checks passed
@github-actions

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 7275 core/libs/CMakeLists.txt
PR 8650 core/libs/CMakeLists.txt
PR 9156 core/libs/CMakeLists.txt
PR 9293 core/libs/CMakeLists.txt
PR 9297 core/libs/CMakeLists.txt
PR 9302 core/libs/CMakeLists.txt
PR 9383 core/libs/CMakeLists.txt
PR 12642 core/libs/CMakeLists.txt
PR 16793 core/libs/CMakeLists.txt
PR 20315 core/libs/CMakeLists.txt
PR 23786 core/libs/CMakeLists.txt
PR 24322 core/libs/CMakeLists.txt
PR 24917 core/libs/CMakeLists.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants