Skip to content

perf(labs): serve the listing from lab_daily - #2176

Draft
alanpeixinho wants to merge 5 commits into
kernelci:mainfrom
profusion:perf/lab-listing
Draft

alanpeixinho wants to merge 5 commits into
kernelci:mainfrom
profusion:perf/lab-listing

Conversation

@alanpeixinho

@alanpeixinho alanpeixinho commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #2179. Merge that first. It adds lab_daily as migration 0022, after #2180.

What it is

The labs listing and the lab origins list read lab_daily instead of scanning builds and tests. Each row is one UTC day, one origin, and one lab, with pass, fail, and inconclusive counts for builds, boots, and tests.

recompute_lab_daily rebuilds a day by deleting that day and inserting the counts again from raw rows. Rows with no lab_id are left out. Dummy builds are left out. The cron rebuilds today every hour, and the last 30 days every 6 hours.

Both queries use the normal query cache. Build counts stay at 0 until those builds have a lab_id.

On production, scanning tests for the listing took 12.2 s, and scanning tests for the origins list took 66 to 75 s. The local database has 2,100,330 tests. The listing scan read 1,478,325 of those and returned 16 labs. The same listing read 80 rows from lab_daily. The origins scan read 1,599,999 tests and returned 2 origins. The same list read 120 rows from lab_daily.

Scan tests lab_daily
Listing, maestro, 5 days 1.3 to 1.5 s 0.13 ms
Origins, 30 days 408 ms 0.37 ms

How to test

Run this on a local database.

  • Apply migration 0022_lab_daily.
  • Run python manage.py recompute_lab_daily --days=30.
  • Open /labs, or call GET /api/labs/?origin=maestro&interval_in_days=5 and GET /api/labs/origins/.
  • A lab with lab_id set shows its counts. A lab with lab_id null does not appear.
  • Run python manage.py recompute_lab_daily --day=YYYY-MM-DD a second time. The same day is replaced, and the counts stay the same.

Closes #2165

Made with Cursor

Add hardware_daily_builds and hardware_daily_tests keyed by checkout
day, origin, lab, and platform. Depends on the labs migration already
on main, so no merge migration is required.

Signed-off-by: Alan Peixinho <[email protected]>
Store one row per UTC day, origin, and lab so the listing can sum
counts without scanning builds and tests.

Signed-off-by: Alan Peixinho <[email protected]>
Read the labs listing and lab origins from lab_daily, with no JSON lab
fallback. Cache the listing query, and refresh today hourly and the
last 30 days every 6 hours.

Assisted-by: Cursor Grok 4.7
Closes kernelci#2165

Signed-off-by: Alan Peixinho <[email protected]>
@alanpeixinho
alanpeixinho changed the base branch from main to feat/lab-daily-table October 15, 2026 14:03
@alanpeixinho

Copy link
Copy Markdown
Contributor Author

Depends on #2179. Merge that first. lab_daily is now migration 0022 and depends on #2180.

@alanpeixinho
alanpeixinho changed the base branch from feat/lab-daily-table to main October 15, 2026 14:07

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How complex would be to add an integration test for the aggregation SQL? The current tests cover the day selection and cache calls, but don't test the counts. A small fixture with builds, boots, and tests would help catch incorrect totals or rows being dropped. If this would take too much time now we can open an issue to improve the integration tests coverage in the future

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added it. It might also be a good idea to do something similar to other aggregations as well.

Seed those rows with recompute_lab_daily so the listing aggregate matches production.

Assisted-by: Cursor
Signed-off-by: Alan Peixinho <[email protected]>
Pytest refuses two collected files that share the basename recompute_lab_daily_test.

Assisted-by: Cursor
Signed-off-by: Alan Peixinho <[email protected]>
@alanpeixinho
alanpeixinho marked this pull request as draft October 16, 2026 19:21
Comment on lines +13 to +15
SELECT DISTINCT origin
FROM lab_daily
WHERE day >= CURRENT_DATE - %(interval_in_days)s

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous query used a rolling time window (NOW() - INTERVAL), but this one includes complete calendar days. Is this change intentional? For example, a five-day interval now includes data older than five days. Should we adjust the API semantics or frontend labels to reflect this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt we invalidate the list on cache after the aggregation run?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Labs] Read the labs listing from the labs table only

2 participants