-
Notifications
You must be signed in to change notification settings - Fork 152
feat - database schema & enqueue/dequeue logic #2096
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
base: master
Are you sure you want to change the base?
Conversation
b6137e5
to
d1eb861
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for splitting the PR. Apart from the comments left on code, two high-level comments:
- The database logic currently assumes that each commit/target combo will be benchmarked exactly by one machine ID. This is enough for supporting ARM collectors, but on its own it doesn't support the second big use-case that we would like to have, which is benchmarking a single commit/target combo by multiple machines in parallel, to reduce the latency between getting the results. I hope that it should be possible to use the same/similar DB table schema even for that, but I haven't yet thought about it. I will try to think about how we can shoehorn that onto the proposed DB schema.
- In a similar spirit, it's not clear how rebenchmarking will be actually performed after a potential failure. The code now enables the collector do benchmark a given commit multiple times, but the other tables (
artifact_collection_duration
,collection
,collector_progress
,pstat
) are not really prepared for this. I'm not sure if we should 1) ditch retry logic for now 2) use a separate DB schema for results from the new collector logic or 3) use the old DB schema and somehow make it support retrying. I would say that 3) is the best, I'll try to think about how to do it. - The logic is becoming nasty enough that I would really appreciate if we had some tests for the DB logic. Sadly, we don't really currently have any testing infrastructure prepared for that. I will try to bootstrap it by copying it from some other projects, so that we can write at least some basic sanity checks that run against an actual database.
database/src/pool.rs
Outdated
@@ -178,6 +179,16 @@ pub trait Connection: Send + Sync { | |||
|
|||
/// Removes all data associated with the given artifact. | |||
async fn purge_artifact(&self, aid: &ArtifactId); | |||
|
|||
/// Add a jobs to the queue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Add a jobs to the queue | |
/// Add jobs to the commit queue |
Btw we might want to call it something else than commit (although it's not a bad name). According to our docs/glossary.md, a single act of "running all benchmarks on a single compiler artifact" should be called a "run", but in the database it's actually called a "collection" right now 😆 A bit messy. Maybe we could call it "run queue" to be consistent with the glossary? But I'm fine with keeping the "commit" name for now.
database/src/pool/postgres.rs
Outdated
FROM commit_queue | ||
WHERE target != $1 | ||
AND status IN ('finished', 'in_progress') | ||
AND sha NOT IN ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this subquery. We select commits that are either finished or in progress, but the subquery seems to filter out commits that are finished?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree I don't think we don't need the subquery 👍 , I think;
WHERE target != $1 AND status IN ('finished', 'in_progress')
Is sufficient.
database/src/pool/postgres.rs
Outdated
FROM commit_queue | ||
WHERE target = $1 | ||
AND status = 'queued' | ||
ORDER BY pr ASC, commit_type, sha |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will probably want some CASE WHEN here to assign explicit priorities to the commit types, rather than depending on the string representation. The ordering should be:
- Releases first
- Master commits second, order by oldest PR ascending
- Try commits last, order by oldest PR ascending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've modified the query to have a simple CASE WHEN
ranking system
Structure for 1 queued job:
With this idea the
|
d1eb861
to
0a27dc2
Compare
What I meant is that currently, if you run the same job twice, the
Yeah we would essentially spin up a separate DB for each executed test, we do it like this in a bunch of other bots/services. |
|
Following on from the prototype, this is code only for the database queries and object mapping from the database.
queued
,in_progress
,finished
,failed
. Which is represented as anenum
in the rust code.queued
commit