From 3b692eef9e126371323e307f9bd37eaa2851e787 Mon Sep 17 00:00:00 2001 From: Kevin Longe <273747162+kvlonge@users.noreply.github.com> Date: Mon, 30 Nov 2026 18:50:41 +0000 Subject: [PATCH] test(benchmarks): grow DuckShop Scale to 63 jobs and about 3,600 nodes per group run The UI's scale profiling needs a live group run of at least 3,500 nodes and 60 jobs. More storefront, store, warehouse and ledger instances bring a group run to about 3,570 nodes, and each system's staging, conformed, facts and report folders become their own jobs: 63 in nightly_job_group. A test checks every model belongs to exactly one job. The generator version is now 3. --- benchmarks/duckshop-scale/README.md | 10 +- benchmarks/duckshop-scale/checksum.txt | 2 +- .../duckshop-scale/duckshop_scale/__init__.py | 2 +- .../duckshop-scale/duckshop_scale/project.py | 141 +++++++----------- benchmarks/duckshop-scale/serve.py | 2 +- .../duckshop-scale/tests/test_generator.py | 25 +++- 6 files changed, 79 insertions(+), 103 deletions(-) diff --git a/benchmarks/duckshop-scale/README.md b/benchmarks/duckshop-scale/README.md index f6b2e2a380..d245714507 100644 --- a/benchmarks/duckshop-scale/README.md +++ b/benchmarks/duckshop-scale/README.md @@ -30,13 +30,13 @@ partner API, so a group run takes several minutes on a laptop. | | Count | |---|---| -| Models | 2,746: 1,144 staging, 1,290 intermediate, 312 marts | +| Models | 3,384: 1,448 staging, 1,594 intermediate, 342 marts | | Incremental models | 13, with timestamp cursors | -| Python loaders | 154, one per source instance | -| Sources | 1,144: 154 loaded by the loaders, the rest DuckDB expressions | -| Audits | 314 (`not_null`, `unique`, `accepted_values`) | +| Python loaders | 184, one per source instance | +| Sources | 1,448: 184 loaded by the loaders, the rest DuckDB expressions | +| Audits | 310 (`not_null`, `unique`, `accepted_values`) | | Seeds and unit tests | 2 and 15 | -| Jobs | 21, all members of `nightly_job_group` (about 2,900 nodes per group run) | +| Jobs | 63, all members of `nightly_job_group` (about 3,600 nodes per group run): each system's staging, conformed, facts and reports, and six shared jobs | Each source instance's tables are staged, brought to a shared shape (amounts converted with the `currencies` seed), unioned per system, published as facts with audits, kept incrementally where the diff --git a/benchmarks/duckshop-scale/checksum.txt b/benchmarks/duckshop-scale/checksum.txt index d22cadbc3c..7ee6b11eca 100644 --- a/benchmarks/duckshop-scale/checksum.txt +++ b/benchmarks/duckshop-scale/checksum.txt @@ -1 +1 @@ -generator 2 files 2804 sha256 1cffdb7f28e119bdde519072cfef09f04f1b1e3a80b1c403aa8501a54c76c97d +generator 3 files 3484 sha256 1f412670fe1c780a1692914376f7e713e9a60e21f0672deea0163dd3acbb0449 diff --git a/benchmarks/duckshop-scale/duckshop_scale/__init__.py b/benchmarks/duckshop-scale/duckshop_scale/__init__.py index 6c5bd2b1d3..e05bfc83c6 100644 --- a/benchmarks/duckshop-scale/duckshop_scale/__init__.py +++ b/benchmarks/duckshop-scale/duckshop_scale/__init__.py @@ -4,5 +4,5 @@ regenerate checksum.txt, whenever a change alters any generated file. """ -GENERATOR_VERSION = "2" +GENERATOR_VERSION = "3" PROJECT_NAME = "duckshop_scale" diff --git a/benchmarks/duckshop-scale/duckshop_scale/project.py b/benchmarks/duckshop-scale/duckshop_scale/project.py index 1be90b7720..46e46a2536 100644 --- a/benchmarks/duckshop-scale/duckshop_scale/project.py +++ b/benchmarks/duckshop-scale/duckshop_scale/project.py @@ -18,20 +18,21 @@ from duckshop_scale import GENERATOR_VERSION, PROJECT_NAME #: How many instances of each source system the project integrates, and how many of each system's -#: tables. Together they size the project like a large production project: about 3,300 nodes. +#: tables. Together they size the project like a large production project: about 3,900 nodes, about +#: 3,600 of them built by a group run. INSTANCE_LIMITS: dict[str, int] = { - "storefront": 26, + "storefront": 36, "marketplace": 10, "carrier": 12, - "warehouse": 14, - "store": 24, + "warehouse": 22, + "store": 32, "supplier": 16, "gateway": 6, "ad_network": 10, "messaging": 4, "affiliate": 6, "support": 3, - "ledger": 10, + "ledger": 14, "wholesale": 6, "returns": 6, "catalogue": 1, @@ -697,95 +698,17 @@ def _unit_test(project: Project, table: Table, columns: list[Col]) -> None: ) -_JOBS: tuple[tuple[str, str, str, int], ...] = ( +#: The jobs shared by every system: reference data, the partner loads, history and the reports +#: across systems. Each is (name, description, selector, concurrency). +_SHARED_JOBS: tuple[tuple[str, str, str, int], ...] = ( ("reference_data_job", "Currencies and the instance register", "kind:seed", 2), ("partner_loads_job", "Pull each instance's main table from its partner API", "kind:loader", 4), - ("storefront_staging_job", "Type every storefront table", "sql/models/staging/storefronts", 6), - ( - "storefront_conformed_job", - "Bring storefront tables to the shared shape", - "sql/models/intermediate/storefronts", - 6, - ), - ( - "marketplace_job", - "Marketplace partners, staged and conformed", - "sql/models/staging/marketplaces sql/models/intermediate/marketplaces", - 4, - ), - ( - "fulfilment_job", - "Carriers and warehouses, staged and conformed", - "sql/models/staging/carriers sql/models/intermediate/carriers " - "sql/models/staging/warehouses " - "sql/models/intermediate/warehouses", - 6, - ), - ( - "retail_job", - "Retail stores, staged and conformed", - "sql/models/staging/stores sql/models/intermediate/stores", - 4, - ), - ( - "procurement_job", - "Suppliers, staged and conformed", - "sql/models/staging/suppliers sql/models/intermediate/suppliers", - 4, - ), - ( - "payments_job", - "Payment gateways, staged and conformed", - "sql/models/staging/payments sql/models/intermediate/payments", - 3, - ), - ( - "marketing_job", - "Ad networks, messaging and affiliates, staged and conformed", - "sql/models/staging/advertising sql/models/intermediate/advertising " - "sql/models/staging/messaging " - "sql/models/intermediate/messaging sql/models/staging/affiliates " - "sql/models/intermediate/affiliates", - 4, - ), - ( - "support_job", - "Support desks, staged and conformed", - "sql/models/staging/support sql/models/intermediate/support", - 2, - ), - ( - "finance_job", - "Ledgers, staged and conformed", - "sql/models/staging/ledgers sql/models/intermediate/ledgers", - 4, - ), - ( - "wholesale_job", - "Wholesale desks, staged and conformed", - "sql/models/staging/wholesale sql/models/intermediate/wholesale", - 2, - ), - ( - "returns_job", - "Returns portals, staged and conformed", - "sql/models/staging/returns sql/models/intermediate/returns", - 2, - ), - ( - "catalogue_job", - "The product catalogue, staged and conformed", - "sql/models/staging/catalogue sql/models/intermediate/catalogue", - 2, - ), ( "history_job", "Keep every version of the tables with history", "sql/models/intermediate/history", 4, ), - ("facts_job", "Publish every fact table, with its audits", "sql/models/marts/facts", 6), - ("instance_reports_job", "One overview per source instance", "sql/models/marts/instances", 4), ( "system_reports_job", "Monthly reports and a summary per source system", @@ -796,21 +719,61 @@ def _unit_test(project: Project, table: Table, columns: list[Col]) -> None: ("executive_job", "KPIs, the board pack and its commentary", "sql/models/marts/executive", 1), ) +#: Each system's own work, one job per layer, as a large team splits its nightly build: the job's +#: name suffix, description, the layer folder it builds, and its concurrency for a big and a small +#: system. +_LAYERS: tuple[tuple[str, str, str, int, int], ...] = ( + ("staging", "Type every {system} table", "staging", 4, 2), + ("conformed", "Bring {system} tables to the shared shape", "intermediate", 4, 2), + ("facts", "Publish the {system} facts, with their audits", "marts/facts", 2, 1), + ("reports", "One overview per {system} instance", "marts/instances", 2, 1), +) + +#: The systems with the most instances, whose jobs get more nodes at once. +_BIG_SYSTEMS = frozenset({"storefront", "store", "warehouse", "ledger", "marketplace"}) + +#: Systems small enough to build in one job, every layer together. +_ONE_JOB_SYSTEMS = frozenset({"catalogue"}) + + +def _jobs() -> tuple[tuple[str, str, str, int], ...]: + """Every job of the nightly group: the shared ones, then each system's, in a fixed order.""" + own: list[tuple[str, str, str, int]] = [] + for system in INSTANCE_LIMITS: + folder = _STAGING_FOLDER[system] + big = system in _BIG_SYSTEMS + if system in _ONE_JOB_SYSTEMS: + select = " ".join(f"sql/models/{layer}/{folder}" for _, _, layer, _, _ in _LAYERS) + description = f"The {folder}, staged, conformed and published" + own.append((f"{folder}_job", description, select, 2)) + continue + for suffix, description, layer, big_concurrency, concurrency in _LAYERS: + own.append( + ( + f"{folder}_{suffix}_job", + description.format(system=system.replace("_", " ")), + f"sql/models/{layer}/{folder}", + big_concurrency if big else concurrency, + ) + ) + return _SHARED_JOBS + tuple(own) + def _orchestration(project: Project) -> None: - for name, description, select, concurrency in _JOBS: + jobs = _jobs() + for name, description, select, concurrency in jobs: project.write( f"orchestration/jobs/{name}.toml", f'name = "{name}"\ndescription = "{description}"\nselect = "{select}"\n' 'owner = "Data platform"\n\n' f"[settings]\nconcurrency = {concurrency}\n", ) - jobs = ",\n".join(f' "{name}"' for name, *_ in _JOBS) + members = ",\n".join(f' "{name}"' for name, *_ in jobs) project.write( "orchestration/job_groups/nightly_job_group.toml", 'name = "nightly_job_group"\n' 'description = "The nightly build: load, stage, conform, publish and report"\n' - f'jobs = [\n{jobs},\n]\nowner = "Data platform"\n' + f'jobs = [\n{members},\n]\nowner = "Data platform"\n' 'schedule = { cron = "0 2 * * *", timezone = "Europe/London", ' 'default_status = "paused" }\n', ) diff --git a/benchmarks/duckshop-scale/serve.py b/benchmarks/duckshop-scale/serve.py index 63e480dc6e..a74edd96fd 100644 --- a/benchmarks/duckshop-scale/serve.py +++ b/benchmarks/duckshop-scale/serve.py @@ -4,7 +4,7 @@ Generates the project when the directory doesn't exist, starts `sqb dev` on it (the server, the scheduler and a code location, on loopback and without sign-in), waits for the first publication and -starts `nightly_job_group`. The run builds about 2,900 nodes in 21 member jobs and lasts several +starts `nightly_job_group`. The run builds about 3,600 nodes in 63 member jobs and lasts several minutes; open the address `sqb dev` prints to watch it. Stop with Ctrl+C. """ diff --git a/benchmarks/duckshop-scale/tests/test_generator.py b/benchmarks/duckshop-scale/tests/test_generator.py index 9d54836e75..8db0210e47 100644 --- a/benchmarks/duckshop-scale/tests/test_generator.py +++ b/benchmarks/duckshop-scale/tests/test_generator.py @@ -47,12 +47,13 @@ def test_given_the_project_when_counting_then_it_is_sized_like_a_large_productio len(re.findall(r"\bnot_null\b|\bunique\b|\baccepted_values\b", t)) for t in models.values() ) incremental = [t for t in models.values() if "materialized incremental" in t] - # About 3,300 nodes in all: models, loaders, audits and seeds. - assert 2_700 <= len(models) <= 2_800 - assert len(loaders) == 154 + # About 3,900 nodes in all: models, loaders, audits and seeds; a group run builds about 3,600. + assert 3_300 <= len(models) <= 3_450 + assert len(loaders) == 184 assert audits >= 300 assert len(incremental) >= 10 - assert 3_100 <= len(models) + len(loaders) + audits + 2 <= 3_400 + assert 3_500 <= len(models) + len(loaders) + 2 <= 3_650 + assert 3_800 <= len(models) + len(loaders) + audits + 2 <= 3_950 def test_given_the_nightly_group_when_reading_it_then_it_runs_every_job() -> None: @@ -63,10 +64,22 @@ def test_given_the_nightly_group_when_reading_it_then_it_runs_every_job() -> Non ) group = files()["orchestration/job_groups/nightly_job_group.toml"] members = re.findall(r'^ "([a-z_]+)",$', group, re.M) - assert 18 <= len(jobs) <= 24 + assert 60 <= len(jobs) <= 66 assert sorted(members) == jobs +def test_given_the_nightly_group_when_reading_its_jobs_then_each_model_is_in_exactly_one() -> None: + folders = [ + word + for path, text in files().items() + if path.startswith("orchestration/jobs/") + for word in re.findall(r'^select = "([^"]*)"$', text, re.M)[0].split() + if word.startswith("sql/models/") + ] + owners = {path: [f for f in folders if path.startswith(f"{f}/")] for path in _models()} + assert [path for path, found in owners.items() if len(found) != 1] == [] + + def test_given_the_project_when_reading_it_then_the_failures_on_purpose_are_there() -> None: project = files() assert "raise ConnectionError(" in project["python/nodes/loaders/partner_feeds/loaders.py"] @@ -95,7 +108,7 @@ def test_given_the_written_project_when_compiling_then_it_has_no_errors_or_warni result = subprocess.run([_sqb(), "compile"], cwd=written, capture_output=True, text=True) assert result.returncode == 0, result.stdout[-3000:] + result.stderr[-3000:] assert re.search( - r"Project compiled\s+2\d{3} models, 2 seeds, 0 functions, 0 errors, 0 warnings", + r"Project compiled\s+3\d{3} models, 2 seeds, 0 functions, 0 errors, 0 warnings", result.stdout + result.stderr, )