Repository navigation
Buffer solver statistics per nonlinear solve to fix threaded counts - #4351
singhharsh1708 wants to merge 1 commit into
Conversation
59dd624 to
69be02c
Compare
69be02c to
eb88a46
Compare
674bacc to
73e511e
Compare
|
Does this impact the timings for non-multithreaded solves? Seems like the locks could have an overhead. |
73e511e to
1b00cf0
Compare
|
Measured it: with the lock on every solve, KenCarp4 on Robertson lost 13% at four Julia threads (nothing at one). Now the delta only exists for threaded algorithms and the drain skips the lock on a single thread; timings are within noise of master at one and four threads (numbers in the body). |
402e35a to
cd51038
Compare
|
I independently checked the overhead at base The clearest result is the stats-path microbenchmark on the PR code (10,000 BenchmarkTools samples, zero allocations in every case):
The end-to-end BenchmarkTools runs showed identical allocation counts and bytes on both revisions for Robertson with KenCarp4/TRBDF2/FBDF/Rodas5P, for 1,000-step fixed-step KenCarp4/TRBDF2 stress cases, and for serial PDIRK44. Threaded PDIRK44 added 2 allocations / 128 bytes per The repository's CI benchmark jobs provide the cleaner end-to-end timing comparison because this shared host was heavily loaded during my run:
All four CI ratio intervals include 1. Together with the direct measurement of roughly 2 ns per non-threaded counter update, I do not see evidence of a measurable non-threaded regression. The threaded path does have the expected fixed cost: about 87 ns for a representative buffered update/drain sequence and 128 bytes per PDIRK44 solve in this case. Commands used for the local measurements were the equivalent of: taskset -c 47 env JULIA_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 julia +1.10.12 --startup-file=no --project=<pr-benchmark-env> micro_stats.jl
taskset -c 44-47 env JULIA_NUM_THREADS=4 OPENBLAS_NUM_THREADS=1 julia +1.10.12 --startup-file=no --project=<pr-benchmark-env> micro_stats.jlCI details: Julia LTS benchmark job, Julia latest benchmark job. 🤖 Benchmarked and drafted by an AI agent using Codex (harness version: unknown; model ID: unknown; session: local session, no shareable URL exposed). |
d36849d to
ce086b1
Compare
ce086b1 to
ae4f358
Compare
|
Matches what I measured: the fixed cost stays on the threaded path and the non-threaded lanes sit inside noise. CI is green on the rebase now. |
|
This isn't the right solution, #4465 is better, though I'm not sure we actually want to do this quite yet... |
Nonlinear solves of a threaded algorithm now accumulate
nf,nw,nsolve,njacs,nnonliniterandnnonlinconvfailin a per-solveStatsDeltaand fold them intointegrator.statsonce per solve, so solvers that run several solves concurrently (PDIRK44) stop losing increments and report the same statistics on every run.jacobian!andjacobiantake astats_sinkkeyword andcalc_J!passes the solver cache's, since counts charged while building a Jacobian were a second source of drift.NonlinearSolve and the QA projects of PDIRK, Extrapolation and IMEXMultistep get the
OrdinaryDiffEqCorepath source SDIRK and Differentiation already have, because those environments were resolving Core from the registry and precompiling the new code against a Core without these names.OrdinaryDiffEqCoregoes to 4.17.0 rather than a patch, since it gains ten public names.The Core compat floors of Differentiation and NonlinearSolve still say 4.12 and 4.13 while their new code needs 4.17, so a registry resolution can pair them with a Core that lacks these names. Raising the floors cannot be done here: it makes every environment that takes Core from the registry unsatisfiable until 4.17.0 is released, so it belongs in a follow-up after this lands.
stats_delta_tests.jlcovers the buffering.Cost on the single-threaded path: the delta is only allocated for an algorithm whose
threadingis on (PDIRK today), every other nonlinear solve charges straight intointegrator.statsas before, and the drain folds without the lock when Julia has one thread. Measured with BenchmarkTools on Robertson at 1e-8, this branch against master: KenCarp4 9.91 vs 9.90 ms at one thread and 10.07 vs 9.93 at four, TRBDF2 6.97 vs 6.97 and 7.07 vs 6.97, FBDF and Rodas5P unchanged; taking the lock on every solve had cost 13% on KenCarp4 at four threads, which is what this avoids.AI Disclosure: Claude assisted with this change.