Skip to content

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

Open
alanpeixinho wants to merge 1 commit into
kernelci:mainfrom
profusion:perf/lab-listing
Open

alanpeixinho wants to merge 1 commit into
kernelci:mainfrom
profusion:perf/lab-listing

Conversation

@alanpeixinho

Copy link
Copy Markdown
Contributor

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 0021_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 a lab_daily aggregate and recompute it from builds and tests.
* Read the labs listing and lab origins from that table, 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 <alan.peixinho@profusion.mobi>

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

1 participant