Repository navigation
harness: benchmark-external engine runs over one run directory, report, and cgroup v2 server CPU and memory - #261
Merged
Merged
Conversation
The engine traits, records and every module of the harness core, with todo!() bodies; ThreadCpuTime in aqpbm-core with its unit test. The implementation follows once the tests are approved.
82 tests from the approved S1 plan: machine key, protocol, fit with leave-one-setting-out, accuracy curves, data and data statistics, the fake engine and conformance kit, run directory, gate and sweep, and the dependency rule. 31 are moved or adapted from ASAPPlanner #1332. They compile against the todo!() skeleton and fail there, except the dependency rule, which already holds.
The engine traits, measurement protocol (idle check, pinning, warm-up, median of an odd run count), machine key, relative-weighted fit with leave-one-setting-out, accuracy curves, data chunks and statistics, run records and directory, gate and sweep arithmetic, the fake-clock engine and the conformance kit. aqpbm-core's ThreadCpuTime reads CLOCK_THREAD_CPUTIME_ID; aqpbm-datagen gains TimeSeriesCursor so a reader can own the generated series and draw samples lazily. All 82 tests pass except the two ignored timing tests (F7, P15).
- H1: a Processes engine is measured on its server pids. ProcessesCpuClock sums utime + stime under a ProcFs (thread CPU 0); run_arm and conformance::check take MeasurementClocks and build the engine's clock from cpu_accounting(). E10 now runs a fake server under a fake /proc. - M1: the calling-thread check repeats each step until 20 ms of CPU, then applies the 10% rule. - M2: answers are keyed by query id outside the labels; QUERY_LABEL deleted. - M3: measure_sizes runs on the protocol, takes a core and a LoadProbe, and returns a Result. - M4: one signed relative error per held-out point. - M5: samples share their series labels (Arc); run_arm documents the memory of its installs; consecutive jobs share one idle sample. - L1-L8 and nits: Option instead of NaN in records, NaN-cost gate failure and zero-duration refusal, private RunDir path and create_new result files, staleness message, FakeClock::ticks deleted, owning into_samples iterator, ConstantNotIdentified doc, relative units tolerance, renames.
Re-pinning the main thread, the process-CPU median, a zombie server pid, server CPU at ns resolution, a nonexistent core refused before the idle sample, and answers freed outside the timed window.
- Pinning reads the process's allowed cores once, before any pin, so the main thread can be re-pinned; a core outside the set is refused before the idle sample. - run_job takes the EngineClock and medians the CPU it measures the engine by (process CPU for Processes engines); MedianClock deleted; measure_sizes moves to protocol.rs and takes the EngineClock too. - Processes engines read their own cgroup v2 cpu.stat usage_usec, else their threads' schedstat (ns); a zombie pid is ProcessExited; the wall clock is read innermost around the call. - run_arm frees every run's answers after the job, outside the timed window. - NodeTerms and InstalledArm::node_terms, ProfilingMethod and MeasurementClocks::os deleted; ranking_agreement takes SelectedAndExactCosts rows; data_statistics groups by label Arc and keeps a running value range. - docs/aqpbm-harness.md, README link, into_samples in the datagen doc; test comments no longer carry PR numbers; generic machine-key example.
zzylol
force-pushed
the
bench-external/run-slice
branch
from
November 17, 2026 14:04
6f7c283 to
af7fa57
Compare
zzylol
force-pushed
the
bench-external/run-slice
branch
from
November 17, 2026 16:46
af7fa57 to
671d399
Compare
The aqpbm-harness crate becomes the harness module of aqpbm-core
(aqpbm_core::harness::{engine, protocol, machine, rundir, records, fit,
accuracy, data, data_stats, gate, sweep, fake, conformance, arm_run}).
Its tests move to aqpbm-core/tests/harness_*.rs, the dependency rule
now checks aqpbm-core with default features off, and the design doc
becomes docs/aqpbm-core-harness.md. aqpbm-core gains only thiserror and
serde's rc feature.
zzylol
force-pushed
the
engines-external/translator
branch
from
November 17, 2026 19:50
8a8dda4 to
4032055
Compare
harness::accuracy becomes harness::error_quantiles, so it no longer reads like core's accuracy comparators; the crate doc points to the harness; the last aqpbm_harness temp-file prefix is renamed.
…kHouse translator New crate `aqpbm-engines-external` (skeleton only) with its tests: - tests/plan_file.rs (R1-R6): reading an ASAPPlanner InstallablePlan file, wire version 15: node fields, label-equality predicates, other wire versions refused, unknown operators kept, standalone scalar queries refused, roots and readers. - tests/clickhouse_translate.rs (X1-X10): tables, materialized views and one query per root against hand-written goldens; the stored-rate substitute recorded; query-time sharing reported; every refused field named at the node that carries it; X10 (ignored) runs the goldens on ClickHouse 26.8.34.13 and checks hand-computed answers. - tests/capability_files.rs (K1): the four deployment-capabilities files equal the hand-computed values. Fixtures are plan files written by the planner for public synthetic workloads (tests/fixtures/plans/REV); edge cases change one field of a loaded fixture in test code.
- X6 also checks root 13, the query-time rate, against F3's query.
- X10's counter data now has three series, one per branch of Prometheus
extrapolatedRate: a reset, a start gap above 1.1 average gaps, and the
zero-point clamp; each rate is computed by hand in the test. X10 also
checks the ClickHouse version first.
- R3 nulls the DAG of the other-version file: the version is read first.
- Mutations use planner wire literals ({"Boolean": true}, {"Float64": 1.0}).
- X4 checks that a label value with a quote and a backslash is escaped.
- X2-X5 assert no substitutions / lost sharing where none are expected.
- REV records how the fixtures were made.
…lickHouse - plan_file.rs: decoder for InstallablePlan wire version 15 over JSON values (no ASAPPlanner dependency). The version is checked first; every field that can change an answer is decoded; unknown operators decode to Other; standalone scalar queries are refused. - clickhouse.rs: translate() refuses, in node id order, every operator and field it has no rule for, then translates each root: stored exact Sum/Count/Min/Max/Rate/Increase chains into AggregatingMergeTree tables and materialized views, query-time builds and Aggregates into SQL over the raw table, with right-closed windows and Prometheus extrapolatedRate. The stored counter chain is recorded as a substitution; query-time nodes shared by several readers are reported as lost sharing. - capabilities/: the four deployment-capabilities files and the README with each entry's class and evidence.
Correctness: - A stored chain's view keeps its Scan's label predicates (WHERE). - A stored read refuses a range that is not a whole number of windows, and every query reports the step its evaluation time must be a multiple of (query_time_steps_ms: the window width it reads, 1 if none). - The decoder checks every id: children, edges and roots name nodes, and a node reads only earlier nodes (no cycle); roots match query texts; versions beyond u32, overflowing or sub-millisecond ranges are refused. - Labels are the utf8 columns of the output schema, not names; a Reduce column must be a label of its input. - Query-time results kept across evaluations are refused (the ClickHouse files say they are not retained). - Measures over a column, unknown measure arguments and quantile levels outside [0, 1] are refused; a grouped SummaryAgg is refused at its node. - The ClickHouse files list no sketch until the translator builds sketch states; the README says so and states the time-order requirement of deltaSumTimestamp states. - Label columns are LowCardinality(String). Simplicity: one StoredChain per chain (BTreeMap), one ExactKind table, one free unsupported(), RawSamples instead of a Raw relation variant; unused fields deleted (wire_version, retention_ms, parameters, the estimate query, the table reference). ClickHouse version: the runs use 26.8.39.13, the 26.8 LTS build for CPUs without AVX2; the goldens pass on it (X10).
Tests first for the independent review of the translator: - Stored rate under parallel reads and partial merges, counter resets inside an insert, at an insert boundary and at a window boundary, single-sample segments, and overlapping segments (ClickHouse, ignored without a server). - Every committed public plan translates, and an equivalent-only one has no substitution; the plans are planner-written from public synthetic workloads at ASAPPlanner #1374 head 7834fed4d (the named fixtures are unchanged). - Grouped query-time summaries (the showcase q4c shape), regrouping merges, top_k, instant selectors, projections and arithmetic binary operators, with hand-computed answers on ClickHouse. - An unaligned evaluation time is an error; retention is recorded with TTL statements kept apart; a NULL value is refused on insert. - Predicate semantics, per-measure filters, the series identity type, the source sorting key, the binary's git hash, and one JSON format for the capability files.
- Stored rate/increase: each stored row is read as one time-ordered segment (finalizeAggregation) and a series' segments are joined in time order, so the answer no longer depends on how a parallel read merges deltaSumTimestamp states (it was 1.7x too high at 16 threads). The step into a segment follows deltaSumTimestamp's own rule; overlapping segments are an error. A new argMax state keeps each segment's last value. - New rules, so that every equivalent-only plan of the public workloads translates: query-time summaries grouped or over another relation (the showcase q4c shape), regrouping merges, grouped stored chains, top_k, instant selectors, Project and arithmetic BinaryOp. A checked division with a value that is not finite is an error. - A stored read fails at an evaluation time that is not a window end. - Retention is decoded and recorded per table; TTL statements are offered apart from the script, for wall-clock data only. - PromQL-semantics label equality only; per-measure filters; the series identity is a String; the source table is sorted by its filtered labels, the series identity and ts, with a minmax index on ts; inserts refuse NULL values; names follow the planner's; the query step travels with each relation; one JSON format for the capability files; the README cites the running binary (26.8.39.13 amd64compat, git hash d5bbb64d) with permalinks.
- A per-series binary operation between two metrics is refused: the series identity names the metric, so a join on it would match nothing where PromQL matches the series without their names. - A metric that only stored chains read is a Null table: its views still see every insert, and no raw rows are kept. - A projection must keep every label and take the value column. - A raw-data Scan read outside a time range or window chain keeps every row (no TTL), as in the planner's raw-data retention. - Names: Relation.unfinalized_kind, whole_number_argument, PlanNode::is_raw_data_scan; the retention_ms doc follows the planner. - README: floating-point summation and the cost of the stored counter read. - Test helpers folded into the common module.
…d capability files ASAPPlanner #1374 is merged into main as bc725bda8. Every committed plan fixture regenerated there is byte-identical, and the four capability files load there unchanged.
zzylol
force-pushed
the
engines-external/translator
branch
from
November 17, 2026 19:51
4032055 to
2ed3d47
Compare
…v2 CPU and memory
…re idle check, the own-group check and the median run
… on the server cores; cgroup CPU only for the engine's own processes
The idle check of a server subtracts the server's own CPU from its cores' busy ticks; agent calls have timeouts and check Content-Length; a cgroup is the server's own only when its child groups hold no foreign process; the data start must be a multiple of the evaluation interval; infinite answers or truths are infinite errors; the report adds the server's memory before the installs and says when a workload has no truth.
…eck forgives tick rounding A range function or aggregation drops __name__ (the fake now does, and the Answers doc says so), so lanes join by label set in the report. The idle check of a server's cores forgives two /proc/stat ticks per core: ticks are 10 ms while the server's CPU is read in microseconds by a separate request.
… result file before any cell runs Found in the first comparison run: a workload whose name held '__' ran its arm and only then failed to write the result.
zzylol
force-pushed
the
bench-external/run-slice
branch
from
November 17, 2026 20:13
31a0040 to
7c0d121
Compare
Collaborator
|
Will update this PR:
#263 and #265 use the agent ( |
…e cgroup agent A server on another host is now read with `ssh <host> cat -- '<file>'` (CgroupSource::Remote) instead of an HTTP agent on that host. Reads to one host share one SSH connection (ControlMaster), never prompt (BatchMode), and fail within seconds on a host that does not answer. Exit status 255 is SSH's own failure (CgroupError::Remote); a missing file such as memory.peak before Linux 5.19 is still NotFound. Removed: the hand-written HTTP/1.0 server and client in aqpbm-core (serve_agent, http_get, agent_in_served_group) and the `approxbench cgroup-agent` command. aqpbm-core opens no network port. Tests: the agent round trip and the own-group check are replaced by a stand-in `ssh` script that runs the command locally (same values as the local directory, quoting of a path with a quote, the shared-connection options) and an SSH failure test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y, relative, evaluation, bytes - lane → engine run: `--lane` → `--engine`, the `lane` column → `engine`, LANES → ENGINES, run_lane → run_engine, LaneSetup/LaneCell/LaneRecord → EngineRunSetup/EngineRunCell/EngineRunRecord, `results/<engine>/lane-<UTC>.json` → `engine-run-<UTC>.json` - RunDir → RunDirectory (module rundir → run_directory, RunDirError → RunDirectoryError, `--run-dir` → `--run-directory`) - max_rel_error, median_rel_error → max_relative_error, median_relative_error - query_cpu_ms_per_eval, engine_counter_cpu_ms_per_eval → ..._per_evaluation - memory columns in bytes (u64) instead of MiB: server_memory_before_bytes, server_memory_after_bytes, server_lifetime_peak_bytes - bench-external → benchmark-external (modules benchmark_external, benchmark_external_cmd; BenchmarkExternal* types; test files renamed) No behavior change besides the memory columns' unit and the file and flag names above. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GordonYuanyc
marked this pull request as ready for review
November 19, 2026 07:56
….ssh, -- before the host - A missing remote file was recognised by `cat`'s English error text; under another locale on the server host, an absent memory.peak became a read error and every cgroup arm failed. The remote command now runs `test -e '<path>' || exit 3; exec cat -- '<path>'`, and exit status 3 is NotFound. - The control socket moves from /tmp/aqpbm-ssh-%C to ~/.ssh/aqpbm-%C: no fixed system path, and no other local user can reach or pre-create it. - `--` before the host, so a host starting with `-` is never read as an ssh option. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- CgroupError::NotServed → NotACgroupFile ("served" was the removed
agent's wording)
- RunDirectoryError::RunDirExists → RunDirectoryExists
- RUN_SUBDIRS → RUN_SUBDIRECTORIES
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What this adds
The first comparison run needs one engine-neutral way to run several engines over the same plans and data, and to read an external server's CPU and memory the same way for every engine. This PR adds that slice of
benchmark-external, tested against the fake engine. The ClickHouse engine follows in the next PR.Example: a run directory with two workloads and two plan variants. Each engine run is a separate process over that directory:
summary.csvthen holds one row per (workload, engine, variant): absolute ingest CPU per sample, query CPU per evaluation, the engine's own per-query counter, server CPU over the whole arm, server memory before and after the installs and its lifetime peak (in bytes), stored bytes of the last install, and the error against the truth engine run (no truthwhen the truth cell did not run). Cells without a plan readno plan: <reason>, and failed cells readnot run: <error>.Run directory read by an engine run
.cell.jsonexists is refused, so results are never overwritten. An engine run can still go variant by variant.substitutions_allowed: falsefails any cell whose engine reports a substitution.Server CPU and memory
CpuAccounting::Cgroup(CgroupSource)reads a server's own cgroup v2 group, either locally or over SSH on the server host (CgroupSource::Remote:ssh <host> cat -- '<file>'). Onlycpu.stat,memory.current,memory.peak,memory.stat,cpuset.cpus.effectiveand the host's/proc/statare read.aqpbm-coreopens no network port.nr_throttledhas grown since the arm started: the server must run without a CPU quota.memory.peakcannot be reset before Linux 6.12, so it is reported as the container's lifetime peak. The arm record also states how many installs were held at once.Processesengine'sCpus_allowed_list. The server's own CPU over the sampling interval is subtracted from those cores' busy ticks, so its own merges never count as foreign load (foreign_busy_fraction).ControlMaster, socket~/.ssh/aqpbm-%C), never prompt (BatchMode), give up on a host that does not answer within 5 s, and on a dead connection within about 15 s. The remote command istest -e '<path>' || exit 3; exec cat -- '<path>', with--before the host. Exit status 255 is SSH's own failure (CgroupError::Remote); 3 is a missing file such asmemory.peakbefore Linux 5.19 (NotFound), whatever the server's locale.ProcessesCpuClockreads a pid's cgroup only when every process in it, and in its child groups, is an engine pid or a descendant of one. Otherwise it falls back toschedstat. The source used is recorded in eachArmResult.cpu_source.measure_sizestakes the median run's units by index (JobRecord.median_run).Interfaces
pub enum CpuAccounting { CallingThread, Processes(Vec<u32>), + Cgroup(CgroupSource), } +pub enum CgroupSource { Local(PathBuf), Remote { ssh_program: String, host: String, cgroup_directory: PathBuf } } +pub struct CgroupCpu { pub usage_ns: u64, pub nr_throttled: u64 } +pub struct CgroupMemory { pub current_bytes: u64, pub anon_bytes: u64, pub file_bytes: u64, pub lifetime_peak_bytes: Option<u64> } pub enum EngineClock<'a> { CallingThread(&'a dyn CpuClock), Processes(ProcessesCpuClock), + Cgroup(CgroupCpuClock), } +impl EngineClock { pub fn cpu_source(&self) -> String } +pub struct ServerCoresProbe { pub cores: Vec<usize>, pub sample_interval: Duration, .. } +pub fn load_probe_for(accounting: &CpuAccounting, files: &ProcessCpuFiles) -> Result<Box<dyn LoadProbe>, ProtocolError> +pub fn parse_cpu_list(text: &str) -> Result<Vec<usize>, ProtocolError> +pub fn foreign_busy_fraction(cores: &[usize], before: &str, after: &str, server_cpu_ns: u64, tick_ns: u64) -> Result<f64, ProtocolError> +pub const CGROUP_FILES: [&str; 5]; pub const PROC_STAT: &str = "proc-stat"; +pub enum CgroupError { Read{..}, NotFound(String), MissingField{..}, Parse{..}, Remote{ host, message }, NotACgroupFile(String) } +pub enum ScheduleError { NoQueries, NoData, ZeroInterval, MixedEvaluationIntervals, UnalignedStart, NoEvaluationTime } +pub struct VariantRecord { pub substitutions_allowed: bool } +pub struct NoPlanRecord { pub reason: String } +pub struct EngineRunRecord { engine, cpu_accounting, protocol, core, args } +pub struct EngineRunCell { engine, workload, variant, outcome: CellOutcome } +pub enum CellOutcome { Ran, NoPlan { reason }, NotRun { error } } +pub struct Report { truth, rows: Vec<ReportRow>, accuracy: Vec<QueryAccuracy> } // + ReportRow, PointErrors, QueryAccuracy +pub fn relative_error(answer: f64, truth: f64) -> f64 +pub fn read_workloads(..); pub fn read_variants(..) +impl FakeServer { pub fn start_in_cgroup(root, pid, cgroup_dir); pub fn charge(&self, ns) } // FakeEngine.ns_per_install +// the fake reads engine_options.plan_file: {} | {"refuse": msg} | {"substitutions": [..]} pub enum ProtocolError { + Cgroup(CgroupError), + CgroupThrottled { nr_throttled: u64 }, } pub struct JobRecord { + pub median_run: usize, } pub struct ArmResult { + pub ingested_samples: u64, + pub server_memory_before: Option<CgroupMemory>, + pub server_memory_after: Option<CgroupMemory>, + pub server_cpu_ns_whole_arm: Option<u64>, + pub cpu_source: String, + pub installs_held: u32, } pub struct PlanSummary { + pub substitutions: Vec<String>, + pub sharing_lost: Vec<String>, } +impl ArmSchedule { pub fn for_workload(workload: &WorkloadSpec) -> Result<ArmSchedule, ScheduleError> } -RunDir, mod rundir +RunDirectory, mod run_directory +impl RunDirectory { pub fn create_at(path: &Path) -> Result<Self, RunDirectoryError>; pub fn open(path: &Path) -> Result<Self, RunDirectoryError> } +pub fn run_engine(run_directory: &RunDirectory, engine: &dyn EngineUnderTest, only_variants: Option<&[String]>, setup: EngineRunSetup) -> Result<Vec<EngineRunCell>, BenchmarkExternalError> +pub fn report(run_directory: &RunDirectory, truth_engine: &str, truth_variant: &str) -> Result<Report, BenchmarkExternalError> +pub fn write_report(run_directory: &RunDirectory, report: &Report) -> Result<(), BenchmarkExternalError> +approxbench benchmark-external run --run-directory R --engine E [--variant V]... [--core C] [--warmup N] [--runs N] [--max-core-busy F] +approxbench benchmark-external report --run-directory R --truth <engine>/<variant>Design scope
aqpbm-core/src/harness/cgroup.rsCpuAccounting::Cgroup,CgroupCpuClock,ServerCoresProbe,load_probe_forCallingThreadandProcesses; the idle check follows the accountingaqpbm-core/src/harness/benchmark_external.rsEngineUnderTestArmSchedule::for_workloadaqpbm-cli/src/benchmark_external_cmd.rsSchedule rule
Evaluation times are the multiples of the workload's evaluation interval, from the data start plus the longest window through the data end. Example: windows of 30 s and 20 s, evaluated every 10 s, over data from 0 ms for 120 s: evaluations at 30,000, 40,000, ..., 120,000 ms. The data start must be a multiple of the interval, so each evaluation time is a refresh-chunk end. A workload whose queries have different intervals is refused.
Not in this PR
Tests
cargo test -p aqpbm-core -p aqpbm-cli,cargo clippy -p aqpbm-core -p aqpbm-cli --all-targets -- -D warningsandcargo fmt --all --checkpass. New tests:aqpbm-core/tests/harness_cgroup.rs: parse, memory, SSH reads through a stand-insshscript (values, quoting, shared-connection options), an SSH failure, clock, throttling, µs quantization, server-core idle probe, foreign pid in the group, and a whole arm on a fake server in its own group.aqpbm-core/tests/harness_arm_schedule.rsaqpbm-core/tests/harness_benchmark_external.rs: engine runs and the hand-computed report rows.aqpbm-core/tests/harness_run_directory.rs:create_atandopen.aqpbm-core/tests/harness_fit.rs: median-run units.aqpbm-cli/tests/benchmark_external_cli.rsUpdates after review
Base is
mainnow that #256 and #260 are merged.ec6e09d: mergemain. harness: aqpbm-core harness module (engine traits, protocol, fit, records, conformance kit) #256 and engines-external: read an ASAPPlanner plan file and translate it to ClickHouse views #260 landed as squash commits, so the merged tree ismainplus this PR's own changes (2ed3d47..7c0d121,aqpbm-coreandaqpbm-clionly).6bf050d: read a remote server's cgroup files over SSH; the cgroup agent (a hand-written HTTP/1.0 server and client inaqpbm-core) andapproxbench cgroup-agentare removed.4b3630e: renames:lane→engine/ engine run,RunDir→RunDirectory,rel→relative,eval→evaluation, memory columns in bytes instead of MiB,bench-external→benchmark-external.8dabe25: SSH reads, from code review: a missing file is decided by exit status, not bycat's English error text; the control socket moves from/tmpto~/.ssh;--before the host.a1609cc: leftover names:NotServed→NotACgroupFile,RunDirExists→RunDirectoryExists,RUN_SUBDIRS→RUN_SUBDIRECTORIES.#263 and #265 use the agent (
--cgroup-agent-url,PUT /server-config) and need the same change.