Girish Maity

Work / Research

Heuristic Foundry

Searches a small, sandboxed formula language for scheduling heuristics on heterogeneous machines, then benchmarks the selected formulas against LPT on sealed held-out workloads. Includes an overfitting case study.

  • Research prototype
  • Recorded run
  • scheduling
  • genetic programming
  • heuristic search
  • benchmarking
  • typescript
  • sqlite

Heuristic Foundry

Problem. Given machines that differ in speed and memory, and jobs that differ in work and memory need, find a simple rule for placing jobs that finishes everything sooner than the classic Longest-Processing-Time rule (LPT), and check honestly whether it does.

Result (recorded)

On five sealed synthetic test sets (150 workloads) that no search ever saw, the best-behaved search arm, evolution seeded with LPT, produced schedules 1.9% shorter than LPT on fresh workloads from the training family: a mean ratio of 0.9813, with a 95% interval of 0.9630-0.9959. It was 2.5% shorter on larger workloads (0.9750), and 1.6% shorter under tighter memory limits (0.9836). On the other two sets the interval includes 1.0, so no difference was shown there. Plain random search came close behind.

The more instructive result is a failure. Evolution without the LPT seed reached the best training score of any arm, then generalised worst. One of its policies placed a single job on the slowest machine and finished almost three times later than LPT.

Two schedule timelines for one skew test workload on the same time axis. Top: LPT, finishing at 76.33. Bottom: the overfit evolved policy, which put the 112-unit job on the slowest machine and finished at 224. A dashed line marks the lower bound of 60.

The page's demo is recorded. It replays exported search histories and allocations from benchmark run 20261109T083629Z-580bcf, and it does not run new searches.

What was built

Everything is TypeScript on Node 24 with no runtime dependencies. SQLite comes from Node's built-in node:sqlite, and TypeScript is only a typechecker. Written for this project:

  • A scheduling engine: the model, the trust-boundary parser for workload files, an independent schedule checker, an exact solver for tiny cases (used in tests), and three baselines.
  • A formula language: a small, allowlisted expression language with a parser, an interpreter with an operation budget (never eval), and limits on depth, size and value.
  • The search: evolutionary and random search with duplicate detection, lineage, atomic checkpoints and deterministic resume. Seeded workload generators produce separate train, validation and test splits, each with a hash manifest.
  • An experiment backend: a SQLite job queue with leases, heartbeats, fencing tokens, retries and cancellation. In a recorded demo, one of two workers was killed while holding a job. That job was recovered on its second attempt, all 160 jobs succeeded, and every result matched an in-process evaluation.
  • A benchmark harness: matched budgets, a test-read ledger written before any test data is opened, paired per-workload ratios, and bootstrap intervals over workloads.

Architecture

workload JSON ──parse/validate──▶ model ──▶ policy (LPT | formula pair) ──▶ schedule ──▶ independent checker
                                               ▲
search (evolution | random) ── proposes formulas, scores on train, selects on validation
        │ checkpoints, lineage                 │
        ▼                                      ▼
  candidates.jsonl              optional: SQLite job queue + worker processes
benchmark: arms × seeds at equal budget ──ledger line──▶ sealed test sets ──▶ paired ratios + bootstrap
export: recorded runs ──▶ results.json + trace.json (+ hashes) ──▶ this page

The key idea: a heuristic is two small formulas

Every policy is a greedy loop. At each step, the priority formula picks which remaining job to place next (highest wins), and the score formula picks which eligible machine gets it (lowest wins). Features are normalised: job work by the largest job, memory by the largest machine, and finish times by the makespan lower bound.

LPT, written in this language, is priority = job_work and score = projected_finish: take the biggest job first, and put it where it finishes earliest. The search looks for other formula pairs, using six safe operators (add sub mul min max safe_div) over eight features.

Example of a better rule. On one fresh test workload (holdout-mixed #40), LPT reached its fourth-largest job, a 31-unit job J15, and found three machines tying on finish time. Its tie-break picked the first listed machine, M0. That is the only machine with enough memory for the next job, J3, which needs 32 units, so J3 had to wait and LPT finished at 61.

The LPT-seeded policy keeps LPT's job order but scores machines by max(machine_capacity, projected_finish). That scores M0 at 1.0 against 0.8857 for the equally fast smaller machines, so J15 goes elsewhere and M0 stays free. The schedule finishes at 35, equal to the lower bound up to floating-point rounding, so it is optimal for that workload.

Benchmark method

  • Budget. Three search arms (random, evolution, and evolution seeded with LPT), each with 5 seeds × 500 candidate evaluations. All train on the same 20 workloads and select on 10 validation workloads.
  • Test sets. Five sealed test sets: fresh draws from the training family, plus three deliberate shifts: larger workloads, heavier work skew, and tighter memory limits.
  • Paired ratio. For each workload, the policy's makespan divided by LPT's on the same workload, averaged over seeds.
  • Interval. The mean over workloads, with a 95% percentile bootstrap that resamples workloads (2000 resamples, seeded).
  • Test-read log. Each read of the test sets is recorded in a ledger before any test file is opened.

Mean makespan ratio against LPT (below 1.0 is better), with 95% intervals:

Test set (workloads)Random searchEvolutionEvolution + LPT seed
Training family, sealed split (10)0.9949 (0.9870-1.0028)1.0009 (0.9918-1.0128)0.9967 (0.9868-1.0087)
Training family, fresh draws (50)0.9888 (0.9681-1.0058)0.9938 (0.9683-1.0262)0.9813 (0.9630-0.9959)
Larger: 6-8 machines, 40-60 jobs (30)0.9770 (0.9524-0.9963)0.9800 (0.9607-0.9943)0.9750 (0.9520-0.9923)
Heavier work skew (30)1.0070 (0.9914-1.0242)1.0269 (1.0001-1.0647)1.0005 (0.9950-1.0053)
Tighter memory (30)0.9784 (0.9541-0.9991)0.9968 (0.9835-1.0122)0.9836 (0.9672-0.9963)

Observations

  • The improvements are small, 1.6-2.5% where an interval excludes 1.0, and they appear on some shifts only.
  • The LPT-seeded arm was the most consistent. It was never clearly worse than LPT.
  • Random search with validation selection had a lower mean than unseeded evolution on all five sets. Without that control arm, "evolution beats LPT" would hide that trying many formulas and validating does most of the work.
  • These are 15 intervals with no multiple-comparison correction, so about one could exclude 1.0 by chance.
  • Formula policies take 4-11× as long as LPT to build a schedule. At this problem size that is microseconds, so it does not matter offline.

Failure case: an evolved rule that overfit

Run 20261109T083641Z-087fb9 (evolution, seed 4):

Train (20 workloads)Validation (10 workloads)
Selected formula1.03981.0628
LPT1.04491.0568

The numbers are mean makespan divided by the lower bound; lower is better. The formula beat LPT on the data it was evolved on and lost on the data it was selected with. Validation selection could only choose among the 8 best training formulas. In this run, all 8 shared the same machine-score structure and scored 1.0628 on validation. On the skew test set, this policy averaged 1.1293× LPT's makespan.

Why it fails. Its machine score is

min( max(job_work, projected_finish),  (job_count + machine_speed) / job_count )

While a job finishes before the lower bound, the first branch is the smaller one, and the rule behaves like "earliest finish". The second branch is a cap just above 1.0, and the cap is lowest on the slowest machine. A job that overshoots the bound on every machine gets capped everywhere, so the slowest machine wins. That only happens for a job that is huge relative to the whole workload.

The training family's long jobs are 20-50 units. In skew test #9, a single job, J15, is 112 of the 270 total units. At step 2, with M1 already busy:

MachineSpeedProjected finish / boundScore (lowest wins)
M00.53.7331.178 (second branch)
M131.2721.272
M211.8671.356

J15 went to M0 and ran for 112 / 0.5 = 224 time units. LPT put it on M1 and finished at 76.33.

On the 20 training workloads the second branch decided 0 of 387 placements, and on the 10 validation workloads 0 of 174, so neither fitness nor selection could see it (experiments/analysis/overfit-branch.ts). Lesson: a search that can express arbitrary branches will find ones its training data never tests. A random-search control, distribution-shifted test sets, and seeding with a known-good rule each helped catch or limit this.

Limitations

  • All data is synthetic, from one seeded generator with four families. Nothing here is measured on real cluster traces.
  • Search trained on one set of 20 workloads. A different training set could change every number above.
  • LPT is the only strong baseline. No local-search post-pass or exact or constraint solver was compared on mid-size instances.
  • The lower bound ignores memory eligibility, so a ratio to it is not an optimality gap.
  • Duplicate detection is textual. Two formulas that behave identically are both evaluated.
  • The job queue gives at-least-once execution on one host. It is not a distributed system.

Reproduce

From the project root, with Node 24:

npm install
npm test
npm run hf -- bench --plan experiments/bench/m4.json --rerun-reason "reproduce"
npm run hf -- export
npm run hf -- serve

The benchmark is deterministic given its plan and seeds; timings vary by machine. The ledger records the rerun reason.

  • All workloads are synthetic, from one seeded generator with four families. Nothing is measured on real cluster traces.
  • Search trained on one set of 20 workloads. Effects against LPT are small (about 1.6-2.5% where present) and appear on some held-out sets only.
  • The 15 benchmark intervals are not corrected for multiple comparisons, and they do not include search-seed variation (reported separately).
  • LPT is the only strong baseline. No local-search post-pass or exact/CP solver was compared on mid-size instances.
  • Demo mode is recorded: the viewer replays exported histories and recomputed allocations. It does not run new searches.
  • The makespan lower bound ignores memory eligibility, so ratios to it are not optimality gaps.
RunRecordedBackendKindCode revision
20261109T083629Z-580bcf2026-11-09 08:36 UTCNode v24.19.0 (V8 13.6.233.17-node.51), Windows_NT 10.0.26200 x64, 16 logical CPUs, single processMeasuredbb2ec0157c0c03623f70f268efc372c58b1ef938+uncommitted
20261109T080546Z-c71f432026-11-09 08:05 UTCNode v24.19.0 (V8 13.6.233.17-node.51), Windows_NT 10.0.26200 x64, 16 logical CPUs, single processMeasured95c8e945a33bea93ea46d0b1e9308b0530f9bec1+uncommitted
20261109T083629Z-d273392026-11-09 08:36 UTCNode v24.19.0 (V8 13.6.233.17-node.51), Windows_NT 10.0.26200 x64, 16 logical CPUs, single processMeasuredbb2ec0157c0c03623f70f268efc372c58b1ef938+uncommitted
20261109T083641Z-087fb92026-11-09 08:36 UTCNode v24.19.0 (V8 13.6.233.17-node.51), Windows_NT 10.0.26200 x64, 16 logical CPUs, single processMeasuredbb2ec0157c0c03623f70f268efc372c58b1ef938+uncommitted
20261109T083648Z-8581e82026-11-09 08:36 UTCNode v24.19.0 (V8 13.6.233.17-node.51), Windows_NT 10.0.26200 x64, 16 logical CPUs, single processMeasuredbb2ec0157c0c03623f70f268efc372c58b1ef938+uncommitted
  • 20261109T083629Z-580bcf: M4 benchmark: 3 search arms x 5 seeds x 500 evaluations, 5 sealed synthetic test sets (150 workloads), read once (experiments/test-ledger.jsonl).
  • 20261109T080546Z-c71f43: M3 job-queue demo: 160 evaluation jobs, 2 worker processes, one killed while holding a job; all 160 succeeded and matched in-process evaluation.
  • 20261109T083629Z-d27339: Search random#1 inside the M4 benchmark. Random-search control: 500 random formulas, best on validation wins.
  • 20261109T083641Z-087fb9: Search evolution#4 inside the M4 benchmark. Overfit case: best train fitness of its arm, worse than LPT on validation.
  • 20261109T083648Z-8581e8: Search evolution+lpt#3 inside the M4 benchmark. Best holdout-mixed seed of the LPT-seeded arm.