perf: measure run/call through the current Observation snapshot

The nine G4 workloads still requested the retired `run/call --json` option,
so every non-check workload exited 2 and was recorded as CORRECTNESS_FAIL; the
RC performance gate could not run at all.

- Request `--output json` for run/call workloads and re-record the committed
  expected digests.
- Pin correctness to the current snapshot: terminal status/result, committed
  stdout/stderr byte digests, and ordered event-kind counts with a sequence
  digest. Run ids, wall-clock stamps and host paths are excluded, so a correct
  program keeps one stable digest.
- Add tooling tests for the workload catalogue and digest stability.
This commit is contained in:
cflmy committed 2026-11-24 20:48:26 +08:00
1 parent 44a118003f
commit 682eae82b6
12 files changed
+1145 -743

No files matched your search

+123
View File
@@ -0,0 +1,123 @@
"""Tests for the performance workload catalogue and correctness digest.
The G4 release gate runs one fixed release binary over nine workloads. A
retired CLI option or a digest that changes per invocation silently turns a
correctness-verified measurement into CORRECTNESS_FAIL, so both are pinned
here.
"""
import importlib.util
import json
import pathlib
import unittest
ROOT = pathlib.Path(__file__).resolve().parents[2]
WORKLOADS = ROOT / "tools" / "perf" / "workloads.json"
RUNNER = ROOT / "tools" / "perf" / "runner.py"
def load_runner():
spec = importlib.util.spec_from_file_location("marqdo_perf_runner", RUNNER)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
def snapshot(run_id: str, status: str, value, extra_file: str = "/tmp/index.mq.md"):
return {
"schema": "marqdo.observation",
"schema_version": 1,
"run": {"id": run_id, "status": status, "source": None},
"capture": {},
"events": [
{
"schema": "marqdo.observation",
"schema_version": 1,
"run_id": run_id,
"seq": 0,
"kind": "stream.opened",
"payload": {"producer": {"name": "marqdo", "version": "3.0.0-rc.3"}},
},
{
"schema": "marqdo.observation",
"schema_version": 1,
"run_id": run_id,
"seq": 1,
"kind": "run.started",
"payload": {"entry": "e::index.mq.md::main", "started_unix_ms": 1795523668882},
},
{
"schema": "marqdo.observation",
"schema_version": 1,
"run_id": run_id,
"seq": 2,
"kind": "run.completed",
"payload": {"status": status, "value": value, "value_type": "Int"},
},
],
}
class WorkloadCatalogueTest(unittest.TestCase):
def test_run_and_call_workloads_use_the_current_output_option(self):
catalogue = json.loads(WORKLOADS.read_text(encoding="utf-8"))
workloads = catalogue["workloads"]
self.assertEqual(len(workloads), 9)
for workload in workloads:
argv = workload["argv"]
if workload["kind"] in ("run", "call"):
self.assertIn(
["--output", "json"],
[argv[index : index + 2] for index in range(len(argv))],
f"{workload['name']} must request the current Observation snapshot",
)
self.assertNotIn(
"--json",
argv,
f"{workload['name']} still passes the retired run/call flag",
)
else:
self.assertIn("--json", argv)
class DigestStabilityTest(unittest.TestCase):
def setUp(self):
self.runner = load_runner()
def test_observation_digest_ignores_run_identity_and_paths(self):
first = self.runner.wire_digest(snapshot("run-1", "ok", 120))
second = self.runner.wire_digest(
snapshot("run-2", "ok", 120, extra_file="/other/host/index.mq.md")
)
self.assertEqual(first, second)
def test_observation_digest_tracks_the_result(self):
ok = self.runner.wire_digest(snapshot("run-1", "ok", 120))
wrong = self.runner.wire_digest(snapshot("run-1", "ok", 121))
failed = self.runner.wire_digest(snapshot("run-1", "error", 120))
self.assertNotEqual(ok, wrong)
self.assertNotEqual(ok, failed)
def test_observation_digest_tracks_the_event_stream(self):
document = snapshot("run-1", "ok", 120)
truncated = dict(document)
truncated["events"] = document["events"][:2]
self.assertNotEqual(
self.runner.wire_digest(document), self.runner.wire_digest(truncated)
)
def test_check_document_keeps_the_command_digest(self):
report = {
"command": "check",
"success": True,
"diagnostics": [{"code": "sem.x", "severity": "error", "line": 1, "column": 2, "message": "m"}],
"stdout": "",
"stderr": "",
}
normalized = self.runner.normalize(report)
self.assertEqual(normalized["command"], "check")
self.assertEqual(len(normalized["diagnostics"]), 1)
if __name__ == "__main__":
unittest.main()
+4
View File
@@ -10,6 +10,10 @@ workload whose wire output did not match the committed expected digest.
`Cargo.lock` digest, `rustc -vV`, source SHA and profile. `Cargo.lock` digest, `rustc -vV`, source SHA and profile.
* Correctness comes first: every warmup run is parsed and hashed. A mismatch * Correctness comes first: every warmup run is parsed and hashed. A mismatch
is `CORRECTNESS_FAIL`; its faster wall time is never reported. is `CORRECTNESS_FAIL`; its faster wall time is never reported.
`run`/`call` workloads request the current Observation snapshot
(`--output json`); the digest pins the terminal status/result, the committed
stdout/stderr byte digests and the ordered event-kind counts, never a run id
or a host path, so it is stable across invocations.
* Approved-node release evidence needs at least 5 warmups and 20 samples per * Approved-node release evidence needs at least 5 warmups and 20 samples per
workload on a dedicated, stable node. A maintainer-approved shared-node workload on a dedicated, stable node. A maintainer-approved shared-node
RC comparison needs the same sample counts in at least three paired runs. RC comparison needs the same sample counts in at least three paired runs.
+281 -254
View File
@@ -1,297 +1,324 @@
{ {
"normalized": { "normalized": {
"command": "run", "events": {
"stderr": "", "by_kind": {
"stdout": "", "branch.eval": 134,
"success": true, "call.enter": 255,
"value": { "call.exit": 255,
"items": [ "effect": 249,
{ "loop.iteration": 40,
"entries": { "parameter.observed": 558,
"ok": { "return": 255,
"type": "bool", "run.completed": 1,
"value": true "run.started": 1,
"stream.opened": 1,
"variable.assigned": 507
},
"count": 2256,
"sequence_sha256": "sha256:7ef37396e4e92c246a44e144f5532b8cefe460cb9bffe4897a561cf42f6a2b4b"
},
"schema": "marqdo.observation",
"status": "ok",
"stderr": {
"bytes": 0,
"sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"stdout": {
"bytes": 0,
"sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"terminal": {
"status": "ok",
"value": {
"items": [
{
"entries": {
"ok": {
"type": "bool",
"value": true
},
"value": {
"decimal": "16",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "16",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "32",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "32",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "16",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "16",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "16",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "16",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "32",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "32",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "56",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "56",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "56",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "56",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "72",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "72",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "96",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "96",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "112",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "112",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "code": {
"entries": { "type": "text",
"code": { "value": "alloc.no_space"
"type": "text", },
"value": "alloc.no_space" "message": {
"type": "text",
"value": "没有足够的空闲空间"
},
"ok": {
"type": "bool",
"value": false
}
}, },
"message": { "type": "map"
"type": "text",
"value": "没有足够的空闲空间"
},
"ok": {
"type": "bool",
"value": false
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "16",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "16",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "32",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "32",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "48",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "48",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "16",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "16",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "code": {
"entries": { "type": "text",
"code": { "value": "alloc.no_space"
"type": "text", },
"value": "alloc.no_space" "message": {
"type": "text",
"value": "没有足够的空闲空间"
},
"ok": {
"type": "bool",
"value": false
}
}, },
"message": { "type": "map"
"type": "text",
"value": "没有足够的空闲空间"
},
"ok": {
"type": "bool",
"value": false
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"type": "none"
}
}, },
"value": { "type": "map"
"type": "none"
}
}, },
"type": "map" {
}, "entries": {
{ "code": {
"entries": { "type": "text",
"code": { "value": "alloc.double_free"
"type": "text", },
"value": "alloc.double_free" "message": {
"type": "text",
"value": "块已在空闲链表"
},
"ok": {
"type": "bool",
"value": false
}
}, },
"message": { "type": "map"
"type": "text",
"value": "块已在空闲链表"
},
"ok": {
"type": "bool",
"value": false
}
}, },
"type": "map" {
}, "decimal": "33",
{ "type": "int"
"decimal": "33", },
"type": "int" {
}, "decimal": "22",
{ "type": "int"
"decimal": "22", },
"type": "int" {
}, "decimal": "33",
{ "type": "int"
"decimal": "33", },
"type": "int" {
}, "decimal": "33",
{ "type": "int"
"decimal": "33", },
"type": "int" {
}, "decimal": "22",
{ "type": "int"
"decimal": "22", },
"type": "int" {
}, "decimal": "44",
{ "type": "int"
"decimal": "44", },
"type": "int" {
}, "decimal": "55",
{ "type": "int"
"decimal": "55", },
"type": "int" {
}, "decimal": "66",
{ "type": "int"
"decimal": "66", },
"type": "int" {
}, "decimal": "77",
{ "type": "int"
"decimal": "77", }
"type": "int" ],
} "type": "list"
], },
"type": "list" "value_type": "List"
} }
}, },
"schema": "marqdo.perf.expected.v1", "schema": "marqdo.perf.expected.v1",
"wire_sha256": "sha256:039ec1523726f48375f1fb5fafdfe849e296e1ee39b8a4820a0a0970cf3f8c3b", "wire_sha256": "sha256:1fc8f64612fe89c66cc38884f31ba2a883c3962a36d431b4e8d224ce8a58922b",
"workload": "allocator-free-list" "workload": "allocator-free-list"
} }
+59 -32
View File
@@ -1,42 +1,69 @@
{ {
"normalized": { "normalized": {
"command": "run", "events": {
"stderr": "", "by_kind": {
"stdout": "", "branch.eval": 51,
"success": true, "call.enter": 7,
"value": { "call.exit": 7,
"items": [ "effect": 28,
{ "loop.iteration": 34,
"entries": { "parameter.observed": 14,
"ok": { "return": 7,
"type": "bool", "run.completed": 1,
"value": true "run.started": 1,
"stream.opened": 1,
"variable.assigned": 66
},
"count": 217,
"sequence_sha256": "sha256:218b342c70a1388d8f9e5ba5843c828ea53fa01c31ddae171c023dd581423f3a"
},
"schema": "marqdo.observation",
"status": "ok",
"stderr": {
"bytes": 0,
"sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"stdout": {
"bytes": 0,
"sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"terminal": {
"status": "ok",
"value": {
"items": [
{
"entries": {
"ok": {
"type": "bool",
"value": true
},
"value": {
"decimal": "36",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "36",
"type": "int"
}
}, },
"type": "map" {
}, "entries": {
{ "ok": {
"entries": { "type": "bool",
"ok": { "value": true
"type": "bool", },
"value": true "value": {
"decimal": "42",
"type": "int"
}
}, },
"value": { "type": "map"
"decimal": "42", }
"type": "int" ],
} "type": "list"
}, },
"type": "map" "value_type": "List"
}
],
"type": "list"
} }
}, },
"schema": "marqdo.perf.expected.v1", "schema": "marqdo.perf.expected.v1",
"wire_sha256": "sha256:418131f5780815da5716d84ed5c00269760a881856cce67e0f4c8b42d417c7ec", "wire_sha256": "sha256:35b915e08c3f69fa0f6375565caaee21393a707d35852d03734b4b9c9643a5c0",
"workload": "bytecode-vm" "workload": "bytecode-vm"
} }
+33 -17
View File
@@ -1,24 +1,40 @@
{ {
"normalized": { "normalized": {
"command": "call", "events": {
"diagnostics": [ "by_kind": {
{ "branch.eval": 9,
"code": "sem.inferred_signature", "call.enter": 5,
"column": 1, "call.exit": 5,
"line": 3, "parameter.observed": 5,
"message": "function signature was inferred; declare it with `params(...)`", "return": 5,
"severity": "warning" "run.completed": 1,
} "run.started": 1,
], "stream.opened": 1,
"stderr": "", "variable.assigned": 4
"stdout": "", },
"success": true, "count": 36,
"value": { "sequence_sha256": "sha256:1c776fb38bbfa9cfb32e907385b18e75d84df3e62d96fee7859a739054513daf"
"decimal": "120", },
"type": "int" "schema": "marqdo.observation",
"status": "ok",
"stderr": {
"bytes": 0,
"sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"stdout": {
"bytes": 0,
"sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"terminal": {
"status": "ok",
"value": {
"decimal": "120",
"type": "int"
},
"value_type": "Int"
} }
}, },
"schema": "marqdo.perf.expected.v1", "schema": "marqdo.perf.expected.v1",
"wire_sha256": "sha256:0cbd8ab0b0e9e671e7e54f707ff2de00181b2721924b7fdec998ff9611873275", "wire_sha256": "sha256:34c724c5abc46f3c38875cf90c23e70e8f4048124a8571665f00f30bbbfab758",
"workload": "factorial-run" "workload": "factorial-run"
} }
+55 -29
View File
@@ -1,36 +1,62 @@
{ {
"normalized": { "normalized": {
"command": "run", "events": {
"stderr": "", "by_kind": {
"stdout": "", "branch.eval": 545,
"success": true, "call.enter": 34,
"value": { "call.exit": 34,
"items": [ "loop.iteration": 756,
{ "parameter.observed": 90,
"decimal": "200", "return": 34,
"type": "int" "run.completed": 1,
}, "run.started": 1,
{ "stream.opened": 1,
"type": "text", "variable.assigned": 1548
"value": "OK" },
}, "count": 3044,
{ "sequence_sha256": "sha256:d394bf12395c193818794d34de4fef9f6a9048eb63235f30ce53a6785c4a2ab5"
"type": "text", },
"value": "text/plain" "schema": "marqdo.observation",
}, "status": "ok",
{ "stderr": {
"type": "text", "bytes": 0,
"value": "hello world" "sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}, },
{ "stdout": {
"type": "text", "bytes": 0,
"value": "GET /health HTTP/1.1\r\nAccept: text/plain\r\nHost: example.test\r\n\r\n" "sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
} },
], "terminal": {
"type": "list" "status": "ok",
"value": {
"items": [
{
"decimal": "200",
"type": "int"
},
{
"type": "text",
"value": "OK"
},
{
"type": "text",
"value": "text/plain"
},
{
"type": "text",
"value": "hello world"
},
{
"type": "text",
"value": "GET /health HTTP/1.1\r\nAccept: text/plain\r\nHost: example.test\r\n\r\n"
}
],
"type": "list"
},
"value_type": "List"
} }
}, },
"schema": "marqdo.perf.expected.v1", "schema": "marqdo.perf.expected.v1",
"wire_sha256": "sha256:540f8dd9a2071d40c1f07d82961e0e0174822e123c828ffc5d2a06cc880052ed", "wire_sha256": "sha256:1617796958d6b8e30c65884f26640f1072cde6037158e3abf0a196ecb9e39712",
"workload": "http-parser" "workload": "http-parser"
} }
+215 -189
View File
@@ -1,199 +1,225 @@
{ {
"normalized": { "normalized": {
"command": "run", "events": {
"stderr": "", "by_kind": {
"stdout": "", "branch.eval": 632,
"success": true, "call.enter": 341,
"value": { "call.exit": 341,
"items": [ "loop.iteration": 208,
{ "parameter.observed": 567,
"entries": { "return": 341,
"next": { "run.completed": 1,
"decimal": "20", "run.started": 1,
"type": "int" "stream.opened": 1,
}, "variable.assigned": 700
"ok": { },
"type": "bool", "count": 3133,
"value": true "sequence_sha256": "sha256:cac83ea2856c09d105554b0e0d3bd1ed3d2541c19af51bddf236ab9b6e87f354"
}, },
"value": { "schema": "marqdo.observation",
"items": [ "status": "ok",
{ "stderr": {
"decimal": "1", "bytes": 0,
"type": "int" "sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}, },
{ "stdout": {
"decimal": "23", "bytes": 0,
"type": "int" "sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}, },
{ "terminal": {
"items": [ "status": "ok",
{ "value": {
"decimal": "4", "items": [
"type": "int" {
}, "entries": {
{ "next": {
"decimal": "5", "decimal": "20",
"type": "int" "type": "int"
}
],
"type": "list"
},
{
"decimal": "-6",
"type": "int"
}
],
"type": "list"
}
},
"type": "map"
},
{
"entries": {
"code": {
"type": "text",
"value": "json.invalid_array"
},
"message": {
"type": "text",
"value": "数组缺少逗号或 ]"
},
"ok": {
"type": "bool",
"value": false
}
},
"type": "map"
},
{
"entries": {
"code": {
"type": "text",
"value": "json.unexpected_eof"
},
"message": {
"type": "text",
"value": "数组未闭合"
},
"ok": {
"type": "bool",
"value": false
}
},
"type": "map"
},
{
"entries": {
"next": {
"decimal": "35",
"type": "int"
},
"ok": {
"type": "bool",
"value": true
},
"value": {
"entries": {
"a": {
"decimal": "1",
"type": "int"
},
"b": {
"items": [
{
"type": "bool",
"value": true
},
{
"type": "none"
},
{
"type": "text",
"value": "说\"好"
}
],
"type": "list"
}
}, },
"type": "map" "ok": {
} "type": "bool",
}, "value": true
"type": "map" },
}, "value": {
{ "items": [
"entries": { {
"next": { "decimal": "1",
"decimal": "6", "type": "int"
"type": "int"
},
"ok": {
"type": "bool",
"value": true
},
"value": {
"type": "text",
"value": "a\nb"
}
},
"type": "map"
},
{
"entries": {
"next": {
"decimal": "37",
"type": "int"
},
"ok": {
"type": "bool",
"value": true
},
"value": {
"items": [
{
"decimal": "1",
"type": "int"
},
{
"type": "float",
"value": 2.5
},
{
"type": "float",
"value": -300.0
},
{
"type": "float",
"value": 0.4
},
{
"entries": {
"a": {
"type": "float",
"value": 1.0
}
}, },
"type": "map" {
}, "decimal": "23",
{ "type": "int"
"type": "text", },
"value": "x" {
} "items": [
], {
"type": "list" "decimal": "4",
} "type": "int"
},
{
"decimal": "5",
"type": "int"
}
],
"type": "list"
},
{
"decimal": "-6",
"type": "int"
}
],
"type": "list"
}
},
"type": "map"
}, },
"type": "map" {
}, "entries": {
{ "code": {
"type": "text", "type": "text",
"value": "[1, 2.5, -300.0, 0.4, {\"a\": 1.0}, \"x\"]" "value": "json.invalid_array"
} },
], "message": {
"type": "list" "type": "text",
"value": "数组缺少逗号或 ]"
},
"ok": {
"type": "bool",
"value": false
}
},
"type": "map"
},
{
"entries": {
"code": {
"type": "text",
"value": "json.unexpected_eof"
},
"message": {
"type": "text",
"value": "数组未闭合"
},
"ok": {
"type": "bool",
"value": false
}
},
"type": "map"
},
{
"entries": {
"next": {
"decimal": "35",
"type": "int"
},
"ok": {
"type": "bool",
"value": true
},
"value": {
"entries": {
"a": {
"decimal": "1",
"type": "int"
},
"b": {
"items": [
{
"type": "bool",
"value": true
},
{
"type": "none"
},
{
"type": "text",
"value": "说\"好"
}
],
"type": "list"
}
},
"type": "map"
}
},
"type": "map"
},
{
"entries": {
"next": {
"decimal": "6",
"type": "int"
},
"ok": {
"type": "bool",
"value": true
},
"value": {
"type": "text",
"value": "a\nb"
}
},
"type": "map"
},
{
"entries": {
"next": {
"decimal": "37",
"type": "int"
},
"ok": {
"type": "bool",
"value": true
},
"value": {
"items": [
{
"decimal": "1",
"type": "int"
},
{
"type": "float",
"value": 2.5
},
{
"type": "float",
"value": -300.0
},
{
"type": "float",
"value": 0.4
},
{
"entries": {
"a": {
"type": "float",
"value": 1.0
}
},
"type": "map"
},
{
"type": "text",
"value": "x"
}
],
"type": "list"
}
},
"type": "map"
},
{
"type": "text",
"value": "[1, 2.5, -300.0, 0.4, {\"a\": 1.0}, \"x\"]"
}
],
"type": "list"
},
"value_type": "List"
} }
}, },
"schema": "marqdo.perf.expected.v1", "schema": "marqdo.perf.expected.v1",
"wire_sha256": "sha256:d6f795f43eb1ae4c3d2f04254b8135f71d717ef8a649efdf7785f172b5381011", "wire_sha256": "sha256:c9833930c28ef238a606db40b33005338e75b83cf9ad98ffaa16f6d9f371a12a",
"workload": "json-parser" "workload": "json-parser"
} }
+148 -123
View File
@@ -1,130 +1,155 @@
{ {
"normalized": { "normalized": {
"command": "run", "events": {
"stderr": "", "by_kind": {
"stdout": "", "call.enter": 2,
"success": true, "call.exit": 2,
"value": { "loop.iteration": 25,
"items": [ "parameter.observed": 2,
{ "return": 2,
"items": [ "run.completed": 1,
{ "run.started": 1,
"items": [ "stream.opened": 1,
{ "variable.assigned": 54
"decimal": "1", },
"type": "int" "count": 90,
}, "sequence_sha256": "sha256:a2b99c523f389a8efd203f54a88f4c9c4ecefe03cf453a3c18ab255913423327"
{ },
"decimal": "2", "schema": "marqdo.observation",
"type": "int" "status": "ok",
}, "stderr": {
{ "bytes": 0,
"decimal": "3", "sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
"type": "int" },
} "stdout": {
], "bytes": 0,
"type": "list" "sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}, },
{ "terminal": {
"items": [ "status": "ok",
{ "value": {
"decimal": "4", "items": [
"type": "int" {
}, "items": [
{ {
"decimal": "5", "items": [
"type": "int" {
}, "decimal": "1",
{ "type": "int"
"decimal": "6", },
"type": "int" {
} "decimal": "2",
], "type": "int"
"type": "list" },
} {
], "decimal": "3",
"type": "list" "type": "int"
}, }
{ ],
"items": [ "type": "list"
{ },
"items": [ {
{ "items": [
"decimal": "7", {
"type": "int" "decimal": "4",
}, "type": "int"
{ },
"decimal": "8", {
"type": "int" "decimal": "5",
} "type": "int"
], },
"type": "list" {
}, "decimal": "6",
{ "type": "int"
"items": [ }
{ ],
"decimal": "9", "type": "list"
"type": "int" }
}, ],
{ "type": "list"
"decimal": "10", },
"type": "int" {
} "items": [
], {
"type": "list" "items": [
}, {
{ "decimal": "7",
"items": [ "type": "int"
{ },
"decimal": "11", {
"type": "int" "decimal": "8",
}, "type": "int"
{ }
"decimal": "12", ],
"type": "int" "type": "list"
} },
], {
"type": "list" "items": [
} {
], "decimal": "9",
"type": "list" "type": "int"
}, },
{ {
"items": [ "decimal": "10",
{ "type": "int"
"items": [ }
{ ],
"decimal": "58", "type": "list"
"type": "int" },
}, {
{ "items": [
"decimal": "64", {
"type": "int" "decimal": "11",
} "type": "int"
], },
"type": "list" {
}, "decimal": "12",
{ "type": "int"
"items": [ }
{ ],
"decimal": "139", "type": "list"
"type": "int" }
}, ],
{ "type": "list"
"decimal": "154", },
"type": "int" {
} "items": [
], {
"type": "list" "items": [
} {
], "decimal": "58",
"type": "list" "type": "int"
} },
], {
"type": "list" "decimal": "64",
"type": "int"
}
],
"type": "list"
},
{
"items": [
{
"decimal": "139",
"type": "int"
},
{
"decimal": "154",
"type": "int"
}
],
"type": "list"
}
],
"type": "list"
}
],
"type": "list"
},
"value_type": "List"
} }
}, },
"schema": "marqdo.perf.expected.v1", "schema": "marqdo.perf.expected.v1",
"wire_sha256": "sha256:c5edb02098191e081a143b8f5d23424fcc43172643a44912cdc8ae17ace99cc2", "wire_sha256": "sha256:b975ac00d3e9d4d01d7e0fd26e0fde152333b254d38e7e1c4195bde824e97f32",
"workload": "matrix-multiply" "workload": "matrix-multiply"
} }
+35 -7
View File
@@ -1,14 +1,42 @@
{ {
"normalized": { "normalized": {
"command": "run", "events": {
"stderr": "", "by_kind": {
"stdout": "[\"文本\", 2, 1.5, [3, true], {a: 1, b: \"x\"}, None]\n[\"文本\", 2, 1.5, [3, true], {a: 1, b: \"x\"}, None]\nTable[名称 | 分数]{甲 | 87; 乙 | 92}\nTable[名称 | 分数]{甲 | 87; 乙 | 92}\n[Formula(\"a = 1\"), Code(\"text\", 9 bytes), FunctionRef(root:default::demo.mq.md::演示函数)]\n[Formula(\"a = 1\"), Code(\"text\", 9 bytes), FunctionRef(root:default::demo.mq.md::演示函数)]\n", "branch.eval": 1956,
"success": true, "call.enter": 131,
"value": { "call.exit": 131,
"type": "none" "effect": 404,
"loop.iteration": 810,
"parameter.observed": 166,
"return": 131,
"run.completed": 1,
"run.started": 1,
"stdout.chunk": 6,
"stream.opened": 1,
"variable.assigned": 2533
},
"count": 6271,
"sequence_sha256": "sha256:e17ea3ebe3ecd40f9e619f06e3bd9d4370d34616caf02a6099bbffe0f686522d"
},
"schema": "marqdo.observation",
"status": "ok",
"stderr": {
"bytes": 0,
"sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"stdout": {
"bytes": 380,
"sha256": "sha256:4f5fcde6b4073511330c50f15bf07db13abc2cf0cf71de777e8e23ca870220fe"
},
"terminal": {
"status": "ok",
"value": {
"type": "none"
},
"value_type": "None"
} }
}, },
"schema": "marqdo.perf.expected.v1", "schema": "marqdo.perf.expected.v1",
"wire_sha256": "sha256:80dfbfb894544b5cd4281999a67deaa9ce4fb19ef32d160fb4ee72dbd615d03c", "wire_sha256": "sha256:7bed5196b8cd52d1de12561f445bc2271dd5e91ed9c4065ebf79d0cb22d8a826",
"workload": "stdlib-print-demo" "workload": "stdlib-print-demo"
} }
+109 -83
View File
@@ -1,94 +1,120 @@
{ {
"normalized": { "normalized": {
"command": "run", "events": {
"stderr": "", "by_kind": {
"stdout": "", "branch.eval": 9,
"success": true, "call.enter": 5,
"value": { "call.exit": 5,
"items": [ "loop.iteration": 10,
{ "parameter.observed": 11,
"header": [ "return": 5,
"名称", "run.completed": 1,
"分数" "run.started": 1,
], "stream.opened": 1,
"rows": [ "variable.assigned": 35
[ },
{ "count": 83,
"type": "text", "sequence_sha256": "sha256:287e3f01941c53559c4113fceded4612a1f6c8ff44d2c19712aebf3c9034a172"
"value": "甲" },
}, "schema": "marqdo.observation",
{ "status": "ok",
"decimal": "87", "stderr": {
"type": "int" "bytes": 0,
} "sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"stdout": {
"bytes": 0,
"sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"terminal": {
"status": "ok",
"value": {
"items": [
{
"header": [
"名称",
"分数"
], ],
[ "rows": [
{ [
"type": "text", {
"value": "乙" "type": "text",
}, "value": "甲"
{ },
"decimal": "92", {
"type": "int" "decimal": "87",
} "type": "int"
}
],
[
{
"type": "text",
"value": "乙"
},
{
"decimal": "92",
"type": "int"
}
],
[
{
"type": "text",
"value": "丙"
},
{
"decimal": "71",
"type": "int"
}
]
], ],
[ "type": "table"
{ },
"type": "text", {
"value": "丙" "header": [
}, "名称",
{ "分数"
"decimal": "71",
"type": "int"
}
]
],
"type": "table"
},
{
"header": [
"名称",
"分数"
],
"rows": [
[
{
"type": "text",
"value": "丙"
},
{
"decimal": "71",
"type": "int"
}
], ],
[ "rows": [
{ [
"type": "text", {
"value": "甲" "type": "text",
}, "value": "丙"
{ },
"decimal": "87", {
"type": "int" "decimal": "71",
} "type": "int"
}
],
[
{
"type": "text",
"value": "甲"
},
{
"decimal": "87",
"type": "int"
}
],
[
{
"type": "text",
"value": "乙"
},
{
"decimal": "92",
"type": "int"
}
]
], ],
[ "type": "table"
{ }
"type": "text", ],
"value": "乙" "type": "list"
}, },
{ "value_type": "List"
"decimal": "92",
"type": "int"
}
]
],
"type": "table"
}
],
"type": "list"
} }
}, },
"schema": "marqdo.perf.expected.v1", "schema": "marqdo.perf.expected.v1",
"wire_sha256": "sha256:12b61dcd9955cb7e137c705e51e29d58322d9525993681170f2dded48e94ee97", "wire_sha256": "sha256:d09caebb0ee91b593a8798f67a082ee38c008ea41274eeef3c05b2a4236081d1",
"workload": "table-sort" "workload": "table-sort"
} }
+67 -1
View File
@@ -17,6 +17,8 @@ performance evidence.
""" """
import argparse import argparse
import base64
from collections import Counter
import hashlib import hashlib
import json import json
import os import os
@@ -64,8 +66,72 @@ def git_sha(repo: Path) -> str:
return output(["git", "-C", str(repo), "rev-parse", "HEAD"]) or "unknown" return output(["git", "-C", str(repo), "rev-parse", "HEAD"]) or "unknown"
OBSERVATION_SCHEMA = "marqdo.observation"
# Run-specific or host-specific payload fields never contribute to correctness.
VOLATILE_PAYLOAD_KEYS = {"file", "started_unix_ms"}
def _stable(value):
"""Drop run/host-specific data from an observation payload."""
if isinstance(value, dict):
return {
key: _stable(item)
for key, item in value.items()
if key not in VOLATILE_PAYLOAD_KEYS
}
if isinstance(value, list):
return [_stable(item) for item in value]
if isinstance(value, str):
return value.replace(str(ROOT), "<repo>")
return value
def _committed_bytes(chunks: list[str]) -> dict:
data = b"".join(base64.b64decode(chunk) for chunk in chunks)
return {
"bytes": len(data),
"sha256": f"sha256:{hashlib.sha256(data).hexdigest()}",
}
def normalize(document: dict) -> dict: def normalize(document: dict) -> dict:
"""Canonical subset used for correctness: no timings, no trace, no paths.""" """Canonical subset used for correctness: no timings, no run ids, no paths."""
if document.get("schema") == OBSERVATION_SCHEMA:
# Current `run`/`call --output json` snapshot: one execution event
# sequence. The run id, wall-clock start and absolute paths are
# per-invocation. Correctness pins the terminal status/result, the
# committed stdout/stderr bytes and the ordered event kinds (count,
# per-kind totals and a sequence digest) without storing thousands of
# structural payloads in the repository.
events = document.get("events") or []
kinds = [event.get("kind") or "" for event in events]
counts = Counter(kinds)
terminal = _stable(events[-1].get("payload")) if events else None
return {
"schema": OBSERVATION_SCHEMA,
"status": (document.get("run") or {}).get("status"),
"terminal": terminal,
"stdout": _committed_bytes(
[
event["payload"]["data_base64"]
for event in events
if event.get("kind") == "stdout.chunk"
]
),
"stderr": _committed_bytes(
[
event["payload"]["data_base64"]
for event in events
if event.get("kind") == "stderr.chunk"
]
),
"events": {
"count": len(events),
"sequence_sha256": "sha256:"
+ hashlib.sha256("\n".join(kinds).encode("utf-8")).hexdigest(),
"by_kind": dict(sorted(counts.items())),
},
}
payload = {} payload = {}
for key in ("command", "success", "value", "stdout", "stderr", "errors"): for key in ("command", "success", "value", "stdout", "stderr", "errors"):
if key in document: if key in document:
+16 -8
View File
@@ -21,7 +21,8 @@
"数学.阶乘", "数学.阶乘",
"--arg", "--arg",
"n=5", "n=5",
"--json" "--output",
"json"
] ]
}, },
{ {
@@ -31,7 +32,8 @@
"argv": [ "argv": [
"run", "run",
"tests/conformance/semantics/55-first-fit-free-list-allocator.mq.md", "tests/conformance/semantics/55-first-fit-free-list-allocator.mq.md",
"--json" "--output",
"json"
] ]
}, },
{ {
@@ -41,7 +43,8 @@
"argv": [ "argv": [
"run", "run",
"tests/conformance/semantics/62-json-array-parser.mq.md", "tests/conformance/semantics/62-json-array-parser.mq.md",
"--json" "--output",
"json"
] ]
}, },
{ {
@@ -51,7 +54,8 @@
"argv": [ "argv": [
"run", "run",
"tests/conformance/semantics/65-table-sort-stdlib.mq.md", "tests/conformance/semantics/65-table-sort-stdlib.mq.md",
"--json" "--output",
"json"
] ]
}, },
{ {
@@ -61,7 +65,8 @@
"argv": [ "argv": [
"run", "run",
"tests/conformance/semantics/63-memory-bytecode-vm.mq.md", "tests/conformance/semantics/63-memory-bytecode-vm.mq.md",
"--json" "--output",
"json"
] ]
}, },
{ {
@@ -71,7 +76,8 @@
"argv": [ "argv": [
"run", "run",
"tests/conformance/semantics/70-matrix-multiply.mq.md", "tests/conformance/semantics/70-matrix-multiply.mq.md",
"--json" "--output",
"json"
] ]
}, },
{ {
@@ -81,7 +87,8 @@
"argv": [ "argv": [
"run", "run",
"tests/conformance/semantics/71-http-parser.mq.md", "tests/conformance/semantics/71-http-parser.mq.md",
"--json" "--output",
"json"
] ]
}, },
{ {
@@ -91,7 +98,8 @@
"argv": [ "argv": [
"run", "run",
"stdlib/demo.mq.md", "stdlib/demo.mq.md",
"--json" "--output",
"json"
] ]
} }
] ]