Repository navigation
Conversation
`__init__` registered `ThreadProc(myid(), tid)` for `tid in 1:Threads.nthreads()`. `nthreads()` counts only the default pool, but Julia numbers the interactive pool first: with an interactive thread (the default since Julia 1.12, or `-t N,1` on 1.10/1.11) thread 1 is interactive and the default pool is threads 2:N+1. So Dagger ran tasks on the interactive thread, where the main task and the REPL live, and never used the last default thread. Measured on Julia 1.12 with `-t 4` (found while checking ThreadPinning.jl against #810): Dagger's ThreadProcs were tids [1, 2, 3, 4], and the CPU pinned to tid 5 never ran Dagger work. This loop dates from 2020-2021, before interactive threads existed, so using thread 1 was never a decision. Register the default pool's tids (`Threads.threadpooltids(:default)`, available since 1.9) instead. Dagger now never schedules tasks on an interactive thread: Julia reserves those for short, latency-sensitive work, and they are where the REPL and usually the eager scheduler's own loop run. Everything that meant "the first thread" by writing a literal 1 now asks for it: - The eager scheduler's long-lived thunk was pinned to `ExactScope(ThreadProc(1, 1))`, which no longer exists when thread 1 is interactive; pin it to the first default-pool thread. - The precompile workload registered `__cpu_thread_1__` directly (`__init__` has not run yet), and that Dict is saved in the package image. `__init__` used to overwrite that entry; now that it registers other names, a stale ThreadProc(1, 1) would survive into every session. Register the first default thread and delete the callback at the end of the workload. `Threads.nthreads()` elsewhere sizes parallel work by the default pool's size, which is still correct. `stealing_permitted` still excludes worker 1's thread 1 (the main thread); when that thread is interactive there is simply no ThreadProc for it. Tests that scheduled on `ThreadProc(1, 1)` or `thread=1` (or on a worker's threads 1 and 2) only passed on 1.12+ because tasks could run on the interactive thread; they now use the real first threads. CI's 1.12+ multithreaded jobs (`-t auto`) have an interactive thread, but 1.10/1.11 do not, so the processors suite also starts a `-t 2,1` subprocess and checks that ThreadProcs are exactly the default pool, that tasks pinned to each run there, and that no task runs on the interactive thread. That test fails on master. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An integer `assignment` array maps each block to "the first CPU thread of the worker" (as docs/src/darray.md says), but the code built `ThreadProc(proc, 1)`. When the worker has an interactive thread, thread 1 is that thread, which no longer has a ThreadProc, so blocks were placed on a processor the scheduler does not know. Use the worker's lowest-numbered registered ThreadProc instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ranks that are neither end of an in-place copy execute it on a plain ThreadProc so that no unrelated GPU context is activated. That was `ThreadProc(myid(), 1)`, which is the interactive thread whenever one exists (test/mpi/run.jl's `--threads=2` gives each rank one on Julia 1.12). Use the first default-pool thread, which Dagger actually schedules on. `first_default_tid` does not allocate, since this runs for every copy on every spectator rank. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record why `1:nthreads()` and literal thread 1 are wrong once an interactive thread exists, and which CI configurations can see it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review finding 1 on PR #841 (blocker): Published thread-1 placements fail when thread 1 is interactive Requested: address as reported; the solution below is the agent's. Explain that exact CPU scopes use the selected worker's Julia thread IDs. The task-affinity and explicit DArray examples discover each worker's processors before selecting a thread. Integer assignments document their first-default-thread behavior as another migration path. On Julia 1.12.6 the old chunk-argument example failed when the selected worker's thread 1 was interactive. The revised examples passed 10/10 checks across workers with zero, one and two interactive threads. Written by an AI agent on jpsamaroo's review feedback.
Review finding 3 on PR #841 (should-fix): Integer DArray assignment rescans each worker’s processor set per grid entry Requested: address as reported; the solution below is the agent's. Snapshot available worker IDs once and reuse each worker's first registered CPU processor across its entries. Fill the final processor array directly and keep the existing direct path for empty and singleton grids so they need no lookup table. On Julia 1.12.6 at -t 4,1, a 256-by-256 grid with one repeated worker ID went from 262189 allocations and 11536008 bytes to 51 allocations and 1050784 bytes per call. The singleton stayed at 46 allocations and 1744 bytes. These are minima of five GC-delta samples after ten warmup calls. The probe also checked inferred grid types, processor IDs and invalid worker rejection. The processor grid suite passed 1782/1782. Written by an AI agent on jpsamaroo's review feedback.
Contributor
Dagger benchmarks:
|
| Backend | Regressions | Improvements | Within noise | Inconclusive metrics | Suites |
|---|---|---|---|---|---|
| Threads | 0 | 2 | 12 | 0 | 4/4 |
| Distributed | 1 | 0 | 3 | 1 | 4/4 |
| Distributed+Threads | 2 | 0 | 1 | 0 | 4/4 |
| MPI | 0 | 0 | 1 | 1 | 4/4 |
| MPI+Threads | 0 | 0 | 25 | 4 | 4/4 |
| Total | 3 | 2 | 42 | 6 | 20/20 |
Regressions across all backends
| Backend | Benchmark | Metric | Change |
|---|---|---|---|
| Distributed+Threads | array/dagger/N=1024 (block 128)/alloc (rand) |
time | +91.5% |
| Distributed+Threads | linalg/dagger/N=1024 (block 128)/lu! (fixed workspace) |
time | +36.2% |
| Distributed | sparse/dagger/N=256 (block 16)/cg solve (laplacian) |
memory | +27.8% |
Improvements across all backends
| Backend | Benchmark | Metric | Change |
|---|---|---|---|
| Threads | linalg/dagger/N=1024 (block 128)/solve (A\b via lu) |
time | -30.2% |
| Threads | stencil/dagger/N=1024 (block 128)/neighbors (Pad) |
time | -28.2% |
Threads (1 process × 4 threads) — 0 regressions, 2 improvements
| Suite | Regressions | Improvements | Within noise | Inconclusive metrics |
|---|---|---|---|---|
| array | 0 | 0 | 2 | 0 |
| linalg | 0 | 1 | 7 | 0 |
| sparse | 0 | 0 | 0 | 0 |
| stencil | 0 | 1 | 3 | 0 |
Improvements
| Benchmark | Metric | Change |
|---|---|---|
linalg/dagger/N=1024 (block 128)/solve (A\b via lu) |
time | -30.2% |
stencil/dagger/N=1024 (block 128)/neighbors (Pad) |
time | -28.2% |
Within noise
| Benchmark | Metric | Change |
|---|---|---|
linalg/dagger/N=256 (block 128)/matvec (A*x) |
time | +64.0% |
stencil/dagger/N=256 (block 256)/multi-expr |
time | +55.8% |
array/dagger/N=1024 (block 512)/norm |
time | +25.9% |
array/dagger/N=256 (block 128)/transpose (permutedims) |
time | -27.4% |
linalg/dagger/N=1024 (block 512)/matvec (A*x) |
time | -27.7% |
stencil/dagger/N=256 (block 128)/alloc (neighbors Wrap) |
time | -29.1% |
stencil/dagger/N=1024 (block 128)/neighbors (Reflect) |
time | -32.0% |
linalg/dagger/N=256 (block 256)/qr |
time | -41.0% |
linalg/dagger/N=256 (block 256)/lu |
time | -42.9% |
linalg/dagger/N=256 (block 128)/syrk (A'*A) |
time | -43.7% |
linalg/dagger/N=256 (block 128)/solve (A\b via lu) |
time | -48.9% |
linalg/dagger/N=256 (block 256)/matvec (A*x) |
time | -53.2% |
Distributed (4 processes × 1 thread) — 1 regressions, 0 improvements
| Suite | Regressions | Improvements | Within noise | Inconclusive metrics |
|---|---|---|---|---|
| array | 0 | 0 | 1 | 0 |
| linalg | 0 | 0 | 2 | 1 |
| sparse | 1 | 0 | 0 | 0 |
| stencil | 0 | 0 | 0 | 0 |
Regressions
| Benchmark | Metric | Change |
|---|---|---|
sparse/dagger/N=256 (block 16)/cg solve (laplacian) |
memory | +27.8% |
Within noise
| Benchmark | Metric | Change |
|---|---|---|
linalg/dagger/N=1024 (block 128)/solve (A\b via lu) |
time | +264.8% |
linalg/dagger/N=1024 (block 128)/matmul (A*A) |
time | +113.4% |
array/dagger/N=1024 (block 512)/alloc (rand) |
time | +40.3% |
Inconclusive metric changes
| Benchmark | Metric | Change |
|---|---|---|
linalg/dagger/N=1024 (block 128)/lu |
time | +100.5% |
Distributed+Threads (2 processes × 2 threads) — 2 regressions, 0 improvements
| Suite | Regressions | Improvements | Within noise | Inconclusive metrics |
|---|---|---|---|---|
| array | 1 | 0 | 0 | 0 |
| linalg | 1 | 0 | 0 | 0 |
| sparse | 0 | 0 | 0 | 0 |
| stencil | 0 | 0 | 1 | 0 |
Regressions
| Benchmark | Metric | Change |
|---|---|---|
array/dagger/N=1024 (block 128)/alloc (rand) |
time | +91.5% |
linalg/dagger/N=1024 (block 128)/lu! (fixed workspace) |
time | +36.2% |
Within noise
| Benchmark | Metric | Change |
|---|---|---|
stencil/dagger/N=1024 (block 512)/neighbors (Wrap) |
time | -38.3% |
MPI (4 ranks × 1 thread) — 0 regressions, 0 improvements
| Suite | Regressions | Improvements | Within noise | Inconclusive metrics |
|---|---|---|---|---|
| array | 0 | 0 | 1 | 0 |
| linalg | 0 | 0 | 0 | 0 |
| sparse | 0 | 0 | 0 | 0 |
| stencil | 0 | 0 | 0 | 1 |
Within noise
| Benchmark | Metric | Change |
|---|---|---|
array/dagger/N=1024 (block 512)/norm |
time | -49.0% |
Inconclusive metric changes
| Benchmark | Metric | Change |
|---|---|---|
stencil/dagger/N=1024 (block 128)/neighbors (Clamp) |
time | +53.3% |
MPI+Threads (2 ranks × 2 threads) — 0 regressions, 0 improvements
| Suite | Regressions | Improvements | Within noise | Inconclusive metrics |
|---|---|---|---|---|
| array | 0 | 0 | 10 | 1 |
| linalg | 0 | 0 | 6 | 0 |
| sparse | 0 | 0 | 0 | 0 |
| stencil | 0 | 0 | 9 | 3 |
Within noise
| Benchmark | Metric | Change |
|---|---|---|
stencil/dagger/N=256 (block 128)/assign (const) |
time | +326.4% |
array/dagger/N=1024 (block 512)/norm |
time | +143.0% |
array/dagger/N=256 (block 256)/add (X + X) |
time | +106.6% |
linalg/dagger/N=1024 (block 128)/matvec (A*x) |
time | +71.7% |
stencil/dagger/N=256 (block 128)/neighbors (Reflect) |
time | +69.7% |
linalg/dagger/N=256 (block 128)/matvec (A*x) |
time | +64.8% |
stencil/dagger/N=256 (block 128)/multi-expr |
time | +59.3% |
array/dagger/N=1024 (block 128)/alloc (rand) |
time | +49.0% |
stencil/dagger/N=1024 (block 512)/neighbors (Wrap) |
time | +48.9% |
linalg/dagger/N=256 (block 256)/qr |
time | +46.0% |
stencil/dagger/N=1024 (block 128)/neighbors (Wrap) |
time | +45.3% |
linalg/dagger/N=256 (block 256)/matvec (A*x) |
time | +43.7% |
stencil/dagger/N=256 (block 128)/neighbors (Pad) |
time | +42.8% |
linalg/dagger/N=256 (block 128)/matmul (A*A) |
time | +42.4% |
array/dagger/N=1024 (block 512)/broadcast (X .+ 1) |
time | +42.4% |
linalg/dagger/N=256 (block 256)/lu |
time | +39.9% |
array/dagger/N=256 (block 128)/norm |
time | +37.9% |
array/dagger/N=256 (block 256)/map (sin.(X)) |
time | +37.2% |
stencil/dagger/N=256 (block 128)/neighbors (Wrap) |
time | -35.0% |
stencil/dagger/N=1024 (block 512)/multi-expr |
time | -38.0% |
stencil/dagger/N=1024 (block 512)/assign (const) |
time | -48.7% |
array/dagger/N=1024 (block 512)/add (X + X) |
time | -51.9% |
array/dagger/N=256 (block 128)/map (sin.(X)) |
time | -57.3% |
array/dagger/N=256 (block 256)/broadcast (X .+ 1) |
time | -58.7% |
array/dagger/N=1024 (block 512)/reduce (sum) |
time | -59.5% |
Inconclusive metric changes
| Benchmark | Metric | Change |
|---|---|---|
array/dagger/N=256 (block 128)/broadcast (X .+ 1) |
time | +108.7% |
stencil/dagger/N=1024 (block 128)/alloc (neighbors Wrap) |
time | +59.2% |
stencil/dagger/N=1024 (block 128)/neighbors (Reflect) |
time | +37.8% |
stencil/dagger/N=1024 (block 128)/neighbors (Pad) |
time | +37.7% |
Full results and plots (download the benchmark-results-* artifacts).
Review finding F4 (should-fix) on PR #841: The MPI spectator change needs final-head evidence and a lasting three-rank case. Use a copy modifier that records the actual execution thread before the ordinary move. Check the payload on every rank and the thread on each spectator. The focused probe passed on three MPICH ranks with two default threads and one interactive thread each. Written by an AI agent on jpsamaroo's review feedback.
Review finding F3 (should-fix) on PR #841: The mixed-pool grid regression has no committed test. Run the placement test with one interactive thread on the driver and two on the worker. Verify that integer assignments use the worker's own first default thread and that the tile data survives collection. Written by an AI agent on jpsamaroo's review feedback.
Preserve master's Datadeps lessons and append the default-thread-pool lesson after them. Written by an AI agent on jpsamaroo's review feedback.
Pick up the merged submission and benchmark-comment changes before validating the processor and Datadeps tests. Written by an AI agent on jpsamaroo's review feedback.
Julia prerelease jobs can include trailing output after a successful child run. The parent treated that line as the result and raised field errors. Run all nine placement assertions inside the child and use the exit status, preserving captured stdout and stderr for diagnostics. Written by an AI agent on jpsamaroo's review feedback.
Ten trivial unpinned tasks can legally finish on one eligible thread. Keep the eligibility assertion for those tasks and use explicit scopes to check that every eligible processor can execute a Datadeps task. The multithreaded Julia 1.13.4 suite passed 757 assertions. Written by an AI agent on jpsamaroo's review feedback.
Review finding (blocker) on PR #841: CPU runners can steal correctly placed Python tasks, bypass PythonExt's ThreadProc exclusion and invoke CPython without its GIL. Registering only default-pool threads exposes this because the protected main-thread runner is no longer a candidate. Check function and argument compatibility before removing a task from another processor's queue. Enter the latest method world for those hooks, since runners may predate a loaded extension. Retain the scope/acceleration and capacity gates before entering that dynamic path. Add a bounded subprocess regression covering callable and argument restrictions after CPU runners have warmed up. Validation: the old queue-stealing path intermittently executes the restricted callable on a CPU; real PythonCall replay segfaults in PyTuple_New. The corrected path passes the restricted-callable probe, the processor suite (32 parent assertions, including the child checks), and eight real Python calls with an interactive thread. Deep-warmed Base.gc_num deltas (10 warmups, GC.gc, minimum of five runs) for a pinned 100-task submission batch: 17,338 allocations /630,224 bytes before, 17,655 /648,384 after. The added checks are required for correctness; existing allocation bounds are unchanged. Written by an AI agent on jpsamaroo's review feedback.
Review finding (nit) on PR #841: the helper docstring used the single interactive-thread range for every -t N,M startup configuration. State the general M+1:M+N range and then identify the usual M=1 case. Checked against the existing mixed-pool processor regression, whose worker starts with two interactive threads and picks Julia thread 3. Written by an AI agent on jpsamaroo's review feedback.
jpsamaroo
added a commit
to AnnaLena77/Dagger_AL.jl
that referenced
this pull request
Nov 30, 2026
Ten zero-work tasks need not visit every eligible processor. The unchanged master fixture intermittently failed when one of four threads was unused, while every actual result still belonged to the requested outer scope. Port the independently reviewed JuliaParallel#841 fixture repair: retain all unpinned membership checks and use one explicitly placed task per eligible processor to prove scope coverage. This tests placement without assuming scheduler fairness. The preceding full Distributed run passed2210 assertions, including every new PR regression, and failed only this unchanged assertion. The same fixture was independently validated in JuliaParallel#841; git diff against master confirms this clause was unchanged by JuliaParallel#798 before this repair. Full Datadeps is rerun before push. Written by an AI agent on jpsamaroo's review feedback.
jpsamaroo
added a commit
that referenced
this pull request
Nov 30, 2026
Ten zero-work tasks need not visit every eligible processor. The merged-master full Datadeps run passed 2297 assertions but hit the known baseline fixture failure when ThreadProc(2,2) was unused. Port the independently validated #841/#798 fixture: retain unpinned membership checks and exercise each eligible processor with one pinned task. Written by an AI agent on jpsamaroo's review feedback.
jpsamaroo
added a commit
to AnnaLena77/Dagger_AL.jl
that referenced
this pull request
Dec 1, 2026
Bring in the current JuliaParallel#815 processor registry, free-CPU execution and normalized scope serialization repairs, including JuliaParallel#841 default-pool registration. Preserve both owner-elision scope constraints and the independent hash/serialization regression tests. Written by an AI agent on jpsamaroo's review feedback.
Port the independently reviewed Python fix from #815 commit c5ccdcc. The work stealer can run a Python callable on a default CPU thread even though Python's GIL is owned by an interactive thread. Route that typed execution through PythonProcessor. Each offload gets a private pinned task and response, preserving captured Python exceptions and distinct concurrent results. Pass only the profiling flag and scalar task ID into that task so cancellation cannot expose recycled Dagger task metadata. Keep the existing branch-specific MPI execution code. This branch predates execute_thread_function. Its typed ThreadProc/Py method therefore preserves the existing inline CPU profiling, latest-world call, and captured-exception wrapper locally, without adding a generic CPU helper. Validation: on this branch's immutable source snapshot, Julia 1.13.4 with 2 default + 1 interactive threads, PythonCall 0.9.37 and Python 3.14.6 passes 6 public NumPy assertions, 10 CPU-dispatch/keyword/error/concurrent-result assertions, the matching 3-assertion stolen-dispatch control, and 2 ordinary CPU controls. The controller exits successfully in a credential-free offline sandbox. These checks do not establish full MPI or backend CI parity. The upstream offload allocation measurement is an intentional correctness tradeoff: after ten 1000-call warmups and five GC-separated samples, 1000 calls change from 112000 B / 6000 allocations to 416000 B / 8000 (+304 B / 2 allocations per call). This branch port does not claim a new whole-package allocation or throughput measurement. Written by an AI agent on jpsamaroo's review feedback.
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.
Problem
Dagger registered thread IDs
1:Threads.nthreads(), even thoughnthreads()counts the default pool and Julia numbers interactive threads first. With Julia 1.12 and-t 4, Dagger ran tasks on interactive thread 1 and left default thread 5 unused. Julia 1.10 and 1.11 show the same behavior with-t 4,1. This surfaced while checking CPU pinning in #810.Change
ThreadProcfor each Julia default-pool thread, usingThreads.threadpooltids(:default).-t 2,1and checks processor registration, exact and unscoped task placement, and integer DArray assignment.Verification
Before rebasing onto current
master, the Processor suite passed 37/37 and the Scopes suite passed 121/121 on Julia 1.12.6 with-t 4,1. The new interactive-pool regression failed against the old base checkout. The rebased diff passesgit diff --check.#826 also targets the MPI driver thread. Its driver-specific tests need to account for configurations where Julia thread 1 is interactive and therefore absent from the Dagger processor list. #815 counts registered
ThreadProcs, which now count only the default pool.Prepared with Claude and Codex.