Skip to content

perf(runs): compute the catalogue signature once per load, not once per trial - #313

Merged
harenome merged 1 commit into
ThinkFlowLab:mainfrom
harenome:perf/catalogue-signature-once
Nov 23, 2026
Merged

harenome merged 1 commit into
ThinkFlowLab:mainfrom
harenome:perf/catalogue-signature-once

Conversation

@harenome

Copy link
Copy Markdown
Collaborator

Closes #310

What

Each trial parse.parse_job reads asked verifier.block_for for its benchmark's report block, and each call checked catalog.signature(), which lists the catalogue folders and stats every benchmark.json: 20,001 calls to load 20,000 trials. verifier.held() now looks the report blocks up once for what runs inside it; parse_job holds them for its trials and workspace.load_jobs for its jobs, so a workspace load checks the catalogue once. Outside a held(), block_for is as before, and the next load sees a catalogue changed since (a benchmark added, a report block edited). The held table is a context variable, so concurrent requests in other threads do not share it.

Touches

backend: app/nullius/runs/verifier.py, app/nullius/runs/parse.py, app/nullius/workspace.py; tests in app/tests/test_workspace.py.

Verified

  • Backend suite: 3214 tests in 169 modules, OK. Route suite: 717 tests in 61 modules, OK. Both in a rootless python:3.12 container.

  • New tests: a load_jobs of 22 trials calls catalog.signature once (22 times before the change); nested held() keeps the outer table, and a catalogue changed between two loads is seen by the second.

  • The first /workspaces after a start, on 20 workspaces of 20 ended Harbor jobs of 50 trials (20,000 trials, the generator in Workspaces: counting a workspace's runs decodes every trial of every job #309), main and this branch alternated on the same profile, 3 starts each, median and range:

    Before the start main this branch
    No job caches 10.1 s (10.0-10.5) 6.5 s (6.1-6.7)
    Caches written before a parse.SCHEMA change 10.9 s (10.7-11.4) 7.3 s (7.1-7.4)

    The next request is 0.02 s on both.

  • cProfile of the start with no caches (werkzeug ProfilerMiddleware):

    main
       ncalls  cumtime  function
          400   10.916  nullius/runs/parse.py:888(parse_job)
        20000    6.620  nullius/runs/verifier.py:133(block_for)
        20001    6.474  nullius/catalogue/catalog.py:281(signature)
    this branch
          400    4.194  nullius/runs/parse.py:888(parse_job)
           21    0.009  nullius/catalogue/catalog.py:281(signature)
    

Risk

A catalogue edited while one load runs is seen by the next load, not halfway through it. Code that reads report blocks outside parse_job and load_jobs (for example Trial.vocab while a page renders) still checks the signature per call, as before. Undone by a revert.

…er trial

Each parsed trial asked verifier.block_for for its report block, and each
call checked catalog.signature(), listing the catalogue folders and stating
every benchmark.json: 20,001 calls for a workspace load of 20,000 trials.
verifier.held() now looks the table up once for a job's trials and once for
a workspace's load_jobs; the next load still sees a changed catalogue.
@harenome
harenome merged commit 76cf715 into ThinkFlowLab:main Nov 23, 2026
2 checks passed
@harenome
harenome deleted the perf/catalogue-signature-once branch November 23, 2026 13:18
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.

Runs: the catalogue signature is computed once per trial when a job is parsed

1 participant