hydra icon indicating copy to clipboard operation
hydra copied to clipboard

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

Open delroth opened this issue 1 year ago • 4 comments

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 https://github.com/NixOS/nixos-org-configurations/issues/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.

delroth avatar Jan 11 '24 19:01 delroth

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.

delroth avatar Jan 11 '24 20:01 delroth

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 :)

Ericson2314 avatar Jan 17 '24 21:01 Ericson2314

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 :+1:

Ma27 avatar Mar 15 '24 13:03 Ma27

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

mweinelt avatar Mar 16 '24 04:03 mweinelt