Split the trial judge into units and run them on a resumable worker pool
The tournament of Phase 13 needs many trials to run on more than one thread and to survive a restart without redoing finished work. The judge was one monolithic call on one thread, so a restart redid the whole trial. TrialRunner.Run is now Judge(Variants()): Variants does every engine execution as a keyed unit in two stages (grid and outside-grid run, then, after the plateau choice, costed runs, benchmark and look-ahead), and Judge is the old pure judging code working on runs assembled by key. Both Run overloads keep their signatures; on one thread the engine is called in the order of today, and the three golden reports do not move. The single low-priority worker becomes a pool of N threads (setting laboratory.workers, default 1, at most one less than the processors, shown in Impostazioni > Sistema). The Laboratory records each unit in the new tournament_units table (migration 0016, which also creates tournaments for the next part of the phase): claimed as running, then done with the gzip of its run. A resumed trial drops its running units, reloads the done ones and runs only the rest; a run reloaded from storage gives the same report byte for byte. Plain trials drop their unit outcomes when they finish or fail. The pool no longer disposes its queue while a thread may still read it. refs #122 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e0a438a0b2
commit
b564871391
15 files changed
+1233
-115
No files matched your search
@@ -35,6 +35,21 @@ public sealed class ArchiveTests
|
||||
("id", Guid.CreateVersion7(_clock.UtcNow)), ("t", _clock.UtcNow), ("m", "Alzato lo stop di BTC/EUR da 65.400 € a 66.180 €."), ("d", new DbJson("{\"from\": \"65400\", \"to\": \"66180\"}"))).ConfigureAwait(false);
|
||||
await s.ExecuteAsync("INSERT INTO users (id, username, password_hash, must_change_password, totp_secret, created_at, updated_at) VALUES (@id, 'admin', 'h', @m, @s, @t, @t)",
|
||||
("id", Guid.CreateVersion7(_clock.UtcNow)), ("m", true), ("s", new byte[] { 0, 1, 2, 255 }), ("t", _clock.UtcNow)).ConfigureAwait(false);
|
||||
|
||||
// A tournament, one of its trials and a unit with its outcome: JSON, bytes and a measure across engines (Phase 13).
|
||||
var tournament = Guid.CreateVersion7(_clock.UtcNow.AddSeconds(40));
|
||||
var trial = Guid.CreateVersion7(_clock.UtcNow.AddSeconds(41));
|
||||
await s.ExecuteAsync(
|
||||
"INSERT INTO tournaments (id, name, plan, plan_hash, status, finalists, created_at, started_at) VALUES (@id, 'Campionato', @p, 'abc', 'running', @f, @t, @t)",
|
||||
("id", tournament), ("p", new DbJson("{\"name\": \"Campionato\", \"cost_multipliers\": [1, 2, 3]}")), ("f", new DbJson("[\"a\", \"b\"]")),
|
||||
("t", _clock.UtcNow)).ConfigureAwait(false);
|
||||
await s.ExecuteAsync(
|
||||
"INSERT INTO backtest_trials (id, strategy, strategy_version, plan, plan_hash, variants, status, created_at, tournament_id) VALUES (@id, 'sma_cross', '1', @p, 'def', 4, 'running', @t, @tour)",
|
||||
("id", trial), ("p", new DbJson("{\"strategy\": \"sma_cross\"}")), ("t", _clock.UtcNow), ("tour", tournament)).ConfigureAwait(false);
|
||||
await s.ExecuteAsync(
|
||||
"INSERT INTO tournament_units (id, trial_id, tournament_id, unit_key, kind, status, outcome, seconds, created_at, finished_at) VALUES (@id, @tr, @tour, 'variant:0:fast=5;slow=20:x1', 'variant', 'done', @o, @sec, @t, @t)",
|
||||
("id", Guid.CreateVersion7(_clock.UtcNow.AddSeconds(42))), ("tr", trial), ("tour", tournament), ("o", new byte[] { 31, 139, 8, 0, 255, 0 }), ("sec", 0.1234567890123),
|
||||
("t", _clock.UtcNow)).ConfigureAwait(false);
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user