Repository navigation
Conversation
…nl#1386) Method-major order let BIOMD0000000457's second corrector method start while its first was still compiling the code both load, so it compiled it again alongside and the doubled codegen tripped the nightly wall alert. schedule() takes depends_on: a spec starts once the one it names has finished, a free worker takes the first ready spec, and with nothing running and nothing ready the first pending starts, so a dependency only orders the work. amici_sens_run makes each later method wait on its own model's first.
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.
Closes #1386.
What was wrong
The nightly
amici_sensleg's wall alert went red on nights when BIOMD0000000457's generated code was compiled twice.make_specsorders the jobs method-major, every model'sstaggeredrun before anysimultaneousone, so that a model's second method would load the code its first had built. Order alone does not keep them apart, though:457 (simultaneous)started while457 (staggered)was still compiling, and compiled the same library again;The fix
This is the issue's option 1, the dispatch dependency. It is deterministic and confined to the harness. Option 2, a build lock in bngsim's codegen cache across processes, would help every suite but touches
python/bngsimwith platform-specific locking, so it is not in this PR._rr_common.schedule(..., depends_on=None):depends_on(spec)gives the key of a spec that must finish, with any result, before this one starts.amici_sens_run:first_method_key(spec, methods)makes each later method wait on its own model's first, andmain()passes it asdepends_on. It is computed from the spec rather than stored on it, so result rows and reports are unchanged.Measured
A simulation of the nightly's dispatch with
timed_worker: 48 models × 2 methods, 3 workers, 0.15 s jobs, and one model's first method taking 15 s and dispatched last in its pass.depends_on(this PR)The wait cost the sweep 0.24 s here (about 1%). On the nightly it saves the second compile of 150-220 s and the contention that slowed the first one.
Tests
test_schedule_starts_a_dependent_spec_only_after_the_one_it_waits_on: and the jobs it does not wait on run meanwhiledepends_on)test_schedule_without_depends_on_starts_the_second_spec_alongside: control, the race itselftest_schedule_runs_a_spec_whose_dependency_times_outtest_schedule_does_not_hold_back_a_spec_waiting_on_no_spec: it starts beside a long job, not after ittest_schedule_runs_every_spec_of_a_dependency_cycletest_each_later_method_waits_on_its_own_models_firstfirst_method_key)test_the_sweep_hands_schedule_the_dependencyMutations
main()does not passdepends_onChecked
parity_checks/tests: 964 passed, 24 skipped, and 2 failed. The same 2 fail on main without this change (test_bngsim_provenance,test_bng_reference_archive, an import path in my local environment).pre-commit run --all-filesandci/changelog.py checkare clean.codegen_secnear 0, as every other model's is.