Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: fix /eval/X/builds requiring 5*len(builds)+1 SQL queries #1335

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

delroth
Copy link
Contributor

@delroth delroth commented Jan 11, 2024

Prefetch related tables that get fetched as part of serialization to JSON. Drop the jobsetevals field since making it efficient is trickier (due to not using DBIx native relationships but instead a many_to_many through a custom table). There is likely a way we could keep it and make it efficient, but I'm not fluent enough in DBIx to know.


More context in NixOS/infra#270 . This used to """""work""""" (painfully inefficiently) but stopped working once the hydra.nixos.org got moved to a separate machine, inducing higher latency costs for each of the hundreds of thousands of SQL queries that need to run to generate the JSON output for this API endpoint.

Prefetch related tables that get fetched as part of serialization to
JSON. Drop the `jobsetevals` field since making it efficient is trickier
(due to not using DBIx native relationships but instead a many_to_many
through a custom table). There is likely a way we could keep it and make
it efficient, but I'm not fluent enough in DBIx to know.
@delroth
Copy link
Contributor Author

delroth commented Jan 11, 2024

Tested on hydra.nixos.org, fetching /builds for haskell-updates eval ID 1798805.

Without change: times out after 15min.
With change: 2min23

Still too slow / too much data for a nixpkgs/trunk eval unfortunately.

@Ericson2314
Copy link
Member

The jobsetevals part I am not sure how to judge. The #1093 folllow-up part definitely seems good. The prefetch part is probably fine too but I don't know this DBX thing :)

@Ma27
Copy link
Member

Ma27 commented Mar 15, 2024

The prefetch part is probably fine too but I don't know this DBX thing :)

Tried this out on my personal instance with query log being activated and that works fine 👍

@mweinelt
Copy link
Member

mweinelt commented Mar 16, 2024

Breaks the nixos-channel-scripts which depend on the jobsetevals field.

https://github.com/NixOS/nixos-channel-scripts/blob/master/mirror-nixos-branch.pl#L103

Ma27 added a commit to Ma27/hydra that referenced this pull request Mar 16, 2024
That way it's possible to observe which queries are fired against the DB
from DBIx. This is particularly useful to find out if DBIx correctly
prefetches everything it needs or if too much / too few things are
loaded, see e.g. NixOS#1335.
@delroth delroth marked this pull request as draft April 20, 2024 14:13
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.

4 participants