-
Notifications
You must be signed in to change notification settings - Fork 875
feat: add provisioning timings to understand slow build times #14274
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
Changes from all commits
7e36010
45b7fb4
38c4197
803a9d4
973ec6d
a070e07
4a29b96
275bfca
73bac3f
3d77c63
c0ae1ba
28fa2f7
68b16ff
6f0b8f8
724f139
c30a900
0d68e69
15282bb
82ca13e
597ec85
805c0f2
46f3318
ebbaf31
eb5ec5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2470,6 +2470,13 @@ func (s *MethodTestSuite) TestSystemFunctions() { | |
JobID: j.ID, | ||
}).Asserts( /*rbac.ResourceSystem, policy.ActionCreate*/ ) | ||
})) | ||
s.Run("InsertProvisionerJobTimings", s.Subtest(func(db database.Store, check *expects) { | ||
// TODO: we need to create a ProvisionerJob resource | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
j := dbgen.ProvisionerJob(s.T(), db, nil, database.ProvisionerJob{}) | ||
check.Args(database.InsertProvisionerJobTimingsParams{ | ||
JobID: j.ID, | ||
}).Asserts( /*rbac.ResourceSystem, policy.ActionCreate*/ ) | ||
})) | ||
s.Run("UpsertProvisionerDaemon", s.Subtest(func(db database.Store, check *expects) { | ||
org := dbgen.Organization(s.T(), db, database.Organization{}) | ||
pd := rbac.ResourceProvisionerDaemon.InOrg(org.ID) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DROP VIEW IF EXISTS provisioner_job_stats; | ||
|
||
DROP TYPE IF EXISTS provisioner_job_timing_stage CASCADE; | ||
|
||
DROP TABLE IF EXISTS provisioner_job_timings; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
CREATE TYPE provisioner_job_timing_stage AS ENUM ( | ||
'init', | ||
'plan', | ||
'graph', | ||
'apply' | ||
johnstcn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
|
||
CREATE TABLE provisioner_job_timings | ||
( | ||
job_id uuid NOT NULL REFERENCES provisioner_jobs (id) ON DELETE CASCADE, | ||
dannykopping marked this conversation as resolved.
Show resolved
Hide resolved
|
||
started_at timestamp with time zone not null, | ||
ended_at timestamp with time zone not null, | ||
stage provisioner_job_timing_stage not null, | ||
source text not null, | ||
action text not null, | ||
resource text not null | ||
dannykopping marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
|
||
CREATE VIEW provisioner_job_stats AS | ||
SELECT pj.id AS job_id, | ||
dannykopping marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pj.job_status, | ||
wb.workspace_id, | ||
pj.worker_id, | ||
pj.error, | ||
pj.error_code, | ||
Comment on lines
+23
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are extraneous right now, but when we slap an API on top of this we'll likely need this info and can save ourselves another database call. |
||
pj.updated_at, | ||
GREATEST(EXTRACT(EPOCH FROM (pj.started_at - pj.created_at)), 0) AS queued_secs, | ||
GREATEST(EXTRACT(EPOCH FROM (pj.completed_at - pj.started_at)), 0) AS completion_secs, | ||
GREATEST(EXTRACT(EPOCH FROM (pj.canceled_at - pj.started_at)), 0) AS canceled_secs, | ||
GREATEST(EXTRACT(EPOCH FROM ( | ||
MAX(CASE WHEN pjt.stage = 'init'::provisioner_job_timing_stage THEN pjt.ended_at END) - | ||
MIN(CASE WHEN pjt.stage = 'init'::provisioner_job_timing_stage THEN pjt.started_at END))), 0) AS init_secs, | ||
GREATEST(EXTRACT(EPOCH FROM ( | ||
MAX(CASE WHEN pjt.stage = 'plan'::provisioner_job_timing_stage THEN pjt.ended_at END) - | ||
MIN(CASE WHEN pjt.stage = 'plan'::provisioner_job_timing_stage THEN pjt.started_at END))), 0) AS plan_secs, | ||
GREATEST(EXTRACT(EPOCH FROM ( | ||
MAX(CASE WHEN pjt.stage = 'graph'::provisioner_job_timing_stage THEN pjt.ended_at END) - | ||
MIN(CASE WHEN pjt.stage = 'graph'::provisioner_job_timing_stage THEN pjt.started_at END))), 0) AS graph_secs, | ||
GREATEST(EXTRACT(EPOCH FROM ( | ||
MAX(CASE WHEN pjt.stage = 'apply'::provisioner_job_timing_stage THEN pjt.ended_at END) - | ||
MIN(CASE WHEN pjt.stage = 'apply'::provisioner_job_timing_stage THEN pjt.started_at END))), 0) AS apply_secs | ||
Comment on lines
+30
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the max(ended_at)-min(started_at) of each stage to determine stage timings. |
||
FROM provisioner_jobs pj | ||
JOIN workspace_builds wb ON wb.job_id = pj.id | ||
LEFT JOIN provisioner_job_timings pjt ON pjt.job_id = pj.id | ||
GROUP BY pj.id, wb.workspace_id; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
INSERT INTO provisioner_job_timings (job_id, started_at, ended_at, stage, source, action, resource) | ||
VALUES | ||
-- Job 1 - init stage | ||
('424a58cb-61d6-4627-9907-613c396c4a38', NOW() - INTERVAL '1 hour 55 minutes', NOW() - INTERVAL '1 hour 50 minutes', 'init', 'source1', 'action1', 'resource1'), | ||
|
||
-- Job 1 - plan stage | ||
('424a58cb-61d6-4627-9907-613c396c4a38', NOW() - INTERVAL '1 hour 50 minutes', NOW() - INTERVAL '1 hour 40 minutes', 'plan', 'source2', 'action2', 'resource2'), | ||
|
||
-- Job 1 - graph stage | ||
('424a58cb-61d6-4627-9907-613c396c4a38', NOW() - INTERVAL '1 hour 40 minutes', NOW() - INTERVAL '1 hour 30 minutes', 'graph', 'source3', 'action3', 'resource3'), | ||
|
||
-- Job 1 - apply stage | ||
('424a58cb-61d6-4627-9907-613c396c4a38', NOW() - INTERVAL '1 hour 30 minutes', NOW() - INTERVAL '1 hour 20 minutes', 'apply', 'source4', 'action4', 'resource4'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
See
InsertProvisionerJobLogs
andInsertProvisionerJob
above