Repository navigation
perf(runs): stop reading every trial of every job on each page - #215
Merged
Merged
Conversation
1 of 11 tasks
A job whose result records a finish with nothing running or pending is read from the cache while its result.json, config.json and folder mtime are unchanged, without stating every trial's files. A resume rewrites result.json and a trial folder added or removed moves the folder, so both are still parsed again; a running job keeps the full signature. Refresh reads every job again.
The trial, judge, reconcile, live-board and builder-like lookups found one job among every job of the workspace. When the open workspace has exactly one folder of that job's name, it alone is read; another workspace asked for, no such folder or several read the whole workspace as before. The job page keeps the whole walk: its Delete groups every launch of the workspace anyway.
The Workspaces page matched every run record against every workspace, resolving the record's folder and each root again for each pair. Each workspace's roots are now resolved once, and each record's folder once per request.
The Launches page walked every run folder on each load. A run still alive is walked at each ask; an ended one again only when its state, its record, its folder or its jobs folder moved. Delete's question walks the folder afresh.
The Runs page asked for_job of every job and launch, each a scan of every run record. execution.owners indexes them once, with for_job's tie-break: the newest start, the first listed of a tie. The Runs page reads it once per request, and the Launches page's own index is the same one, so the two cannot name different runs for a job.
Job.counts walks every trial on each read, and the Runs list read it up to a dozen times per row. The templates that read a job's counts, or a feasibility report's, more than once now read them once into oc. The counts stay a property: a job's trials can change after it is made.
A host run's copy can bring a job's final result.json while a trial's file is still mid-write; the next copy corrects the trial alone, which the head of an ended job does not see. While a run of this application writes a job, the job is checked trial by trial, and its head carries the run's end, so the last copy is checked once more. The web layer passes each run's job_state; a job no run writes is unchanged.
A part's end is written down before the run's last copy from its host, for example under Stop. Counted alone, it let a page cache a job whose trial that copy then corrected. The Delete prompt reads jobs with the same run states.
harenome
force-pushed
the
perf/many-workspaces
branch
from
November 19, 2026 09:56
e35e79d to
9de40ff
Compare
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 #214
What
Each change below makes one cause cheaper and keeps the numbers the same.
workspace.load_job). A job's head is the schema, its folder's mtime, and its top-levelresult.jsonandconfig.json. A job that ended (finished_atset, statefinished) with an unchanged head is read from memory or disk with no per-trial stats. Other jobs keep the full walk. The cache file now carries the head. An older cache learns it on its first rewrite, so no schema bump is needed. Refresh (clear_cache) stays the way to read a job again.shared._job_for_request). Trial, trace, live, judge, judge tasks, reconcile and the builder's?like=find the one folder named for the job. Any doubt falls back to today's full load:?workspace=, a miss, or several folders of that name. A run's own page keeps the full load, because its Delete check reads the whole workspace anyway._real_roots), through a per-request memo,shared.request_memo.execution.run_size). A run in progress is measured at each load. An ended run's size is cached under a lock, keyed on its state, its finish time, and the mtimes of its folder,run.jsonandjobs/.deletion()still measures afresh, so both Delete prompts show the current size.execution.owners()). One dict maps each job to the newest record that names it, with the first one listed winning a tie, asmax(key=started)does.for_jobandended_fortake it. Launches used a different tie-break before, so on equal start times it could name a different run than the Runs page. Now both agree.runs/index.html,runs/job.html,compare/compare.htmlandruns/feasibility.htmlreadcountsonce into a variable.Job.countsstays a property: trials are added after a job is made, so a cached count could go stale.result.jsonwhile it is being written, in the same pass that brings the job's finalresult.json. The final pass then fixes that trial file only, and the head does not move. Soload_jobstakes the owning run's state: none while the run is alive, which turns the shortcut off, and its state and finish time once it ends, which joins the head. The job gets one full check after the last copy. The final copy runs beforeexecution.pyrecords the run's end. A part's own end is recorded before that copy, for example under Stop, so it counts only once the whole run has ended (execution.run_ends). The Delete prompt reads jobs with the same states. A job opened from a folder has no record and takes the shortcut as before.workspace.pystill imports nothing fromexecution.Not done: Workspaces still counts each workspace's launches from its parsed jobs. Exact counts need, for every view, its id, merges, state, launch, dataset, start and check role, which is the parse cache again. After the commits above, the page takes 0.7 s.
Touches
backend (
nullius/workspace.py,nullius/execution.py) · routes (web/shared.py,web/runs.py,web/traces.py,web/judge.py,web/judge_tasks.py,web/reconcile.py,web/builder.py) · templates (runs/index.html,runs/job.html,runs/feasibility.html,compare/compare.html) · testsVerified
A synthetic profile in a rootless Podman container (
python:3.12): 100 workspaces, 2000 Harbor jobs of 50 trials, 200 run records, 480 jobs in the open workspace. Each time below is the median of requests 2 to 5 over two fresh processes, in seconds. Runs vary by about 30%./runs,/runs?view=all,/workspaces,/launches, a run page and a trial page were saved on main and on the branch, on the same data at two sizes (500 and 2000 jobs). After normalising the CSRF tokens, the interface digest and the workspace's "opened" time, they are identical. No count and no size differs.python3 app/tests/parallel.py: 2325 tests in 130 modules, OK.pip install -r app/requirements.txt, thenpython3 app/tests/parallel.py app/ui_tests: 644 tests in 54 modules, OK.test_workspace.py: an ended job is not stated trial by trial, from memory or disk; a resume and a new trial folder read the job again; a running job updates each trial; an old cache learns its head once; the rsync race reads the corrected trial once the run ends, and the test fails without the guard; a folder-opened job takes the shortcut.test_execution_stop.py: a part stopped as it ends gives no end until the run has ended, and the test fails when a part's end counts alone.test_job_lookup.py: one folder,?workspace=, two folders of one name, and a miss.test_run_delete.py: an ended run's size is cached and read again when its folder moves; a Delete prompt measures afresh; a running run is measured at each load.Not checked: a real host run that hits the race, and the docker test tier.
Risk
result.json.shortcut:comment.headfield is ignored by main.