Skip to content

Commit

Permalink
Select proper fields about profiles in the api
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
  • Loading branch information
frouioui committed Nov 14, 2024
1 parent 7d3c358 commit 1637c54
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
29 changes: 7 additions & 22 deletions go/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,17 @@ func (e *Exec) insert() error {

func GetRecentExecutions(client storage.SQLClient) ([]*Exec, error) {
var res []*Exec
query := "SELECT uuid, status, git_ref, started_at, finished_at, source, workload, pull_nb, go_version FROM execution ORDER BY started_at DESC LIMIT 1000"
query := "SELECT uuid, status, git_ref, started_at, finished_at, source, workload, pull_nb, go_version, IFNULL(profile_binary, ''), IFNULL(profile_mode, '') FROM execution ORDER BY started_at DESC LIMIT 1000"
result, err := client.Read(query)
if err != nil {
return nil, err
}
defer result.Close()
for result.Next() {
exec := &Exec{}
err = result.Scan(&exec.RawUUID, &exec.Status, &exec.GitRef, &exec.StartedAt, &exec.FinishedAt, &exec.Source, &exec.Workload, &exec.PullNB, &exec.GolangVersion)
exec := &Exec{
ProfileInformation: &ProfileInformation{},
}
err = result.Scan(&exec.RawUUID, &exec.Status, &exec.GitRef, &exec.StartedAt, &exec.FinishedAt, &exec.Source, &exec.Workload, &exec.PullNB, &exec.GolangVersion, &exec.ProfileInformation.Binary, &exec.ProfileInformation.Mode)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -541,23 +543,6 @@ func GetPreviousFromSourceMacrobenchmark(client storage.SQLClient, source, workl
return
}

// GetLatestDailyJobForMicrobenchmarks will fetch and return the commit sha for which
// the last daily job for microbenchmarks was run
func GetLatestDailyJobForMicrobenchmarks(client storage.SQLClient) (gitSha string, err error) {
query := "select git_ref from execution where source = \"cron\" and status = \"finished\" and workload = \"micro\" order by started_at desc limit 1"
rows, err := client.Read(query)
if err != nil {
return "", err
}

defer rows.Close()
for rows.Next() {
err = rows.Scan(&gitSha)
return gitSha, err
}
return "", nil
}

// GetLatestDailyJobForMacrobenchmarks will fetch and return the commit sha for which
// the last daily job for macrobenchmarks was run
func GetLatestDailyJobForMacrobenchmarks(client storage.SQLClient) (gitSha string, err error) {
Expand Down Expand Up @@ -586,7 +571,7 @@ func Exists(client storage.SQLClient, gitRef, source, workload, status string) (
}

func CountMacroBenchmark(client storage.SQLClient, gitRef, source, workload, status, planner string) (int, error) {
query := "SELECT count(uuid) FROM execution e, macrobenchmark m WHERE e.status = ? AND e.git_ref = ? AND e.workload = ? AND e.source = ? AND m.vtgate_planner_version = ? AND e.uuid = m.exec_uuid"
query := "SELECT count(uuid) FROM execution e, macrobenchmark m WHERE e.profile_binary IS NULL AND e.status = ? AND e.git_ref = ? AND e.workload = ? AND e.source = ? AND m.vtgate_planner_version = ? AND e.uuid = m.exec_uuid"
result, err := client.Read(query, status, gitRef, workload, source, planner)
if err != nil {
return 0, err
Expand Down Expand Up @@ -640,7 +625,7 @@ func GetHistory(client storage.SQLClient) ([]*History, error) {
source,
workload
HAVING
COUNT(*) >= 10
COUNT(*) >= 1
) AS subquery
GROUP BY
git_ref,
Expand Down
29 changes: 21 additions & 8 deletions go/server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ type ErrorAPI struct {
}

type ExecutionQueue struct {
Source string `json:"source"`
GitRef string `json:"git_ref"`
Workload string `json:"workload"`
PullNb int `json:"pull_nb"`
Source string `json:"source"`
GitRef string `json:"git_ref"`
Workload string `json:"workload"`
PullNb int `json:"pull_nb"`
ProfileBinary string `json:"profile_binary"`
ProfileMode string `json:"profile_mode"`
}

type RecentExecutions struct {
Expand All @@ -59,6 +61,8 @@ type RecentExecutions struct {
GolangVersion string `json:"golang_version"`
StartedAt *time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at"`
ProfileBinary string `json:"profile_binary"`
ProfileMode string `json:"profile_mode"`
}

type ExecutionMetadatas struct {
Expand Down Expand Up @@ -102,6 +106,8 @@ func (s *Server) getRecentExecutions(c *gin.Context) {
GolangVersion: e.GolangVersion,
StartedAt: e.StartedAt,
FinishedAt: e.FinishedAt,
ProfileBinary: e.ProfileInformation.Binary,
ProfileMode: e.ProfileInformation.Mode,
})
if !slices.Contains(response.Workloads, e.Workload) {
response.Workloads = append(response.Workloads, e.Workload)
Expand All @@ -124,11 +130,18 @@ func (s *Server) getExecutionsQueue(c *gin.Context) {
if e.Executing {
continue
}
var profileBinary, profileMode string
if e.identifier.Profile != nil {
profileBinary = e.identifier.Profile.Binary
profileMode = e.identifier.Profile.Mode
}
response.Executions = append(response.Executions, ExecutionQueue{
Source: e.identifier.Source,
GitRef: e.identifier.GitRef,
Workload: e.identifier.Workload,
PullNb: e.identifier.PullNb,
Source: e.identifier.Source,
GitRef: e.identifier.GitRef,
Workload: e.identifier.Workload,
PullNb: e.identifier.PullNb,
ProfileBinary: profileBinary,
ProfileMode: profileMode,
})
if !slices.Contains(response.Workloads, e.identifier.Workload) {
response.Workloads = append(response.Workloads, e.identifier.Workload)
Expand Down
5 changes: 4 additions & 1 deletion go/tools/macrobench/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func getExecutionGroupResults(workload string, ref string, planner PlannerVersio
metrics AS m ON e.uuid = m.exec_uuid
WHERE
e.status = 'finished'
AND e.profile_binary IS NULL
AND e.git_ref = ?
AND info.vtgate_planner_version = ?
AND info.workload = ?
Expand Down Expand Up @@ -156,6 +157,7 @@ func getExecutionGroupResultsFromLast30Days(workload string, planner PlannerVers
metrics AS m ON e.uuid = m.exec_uuid
WHERE
e.finished_at BETWEEN DATE(NOW()) - INTERVAL 30 DAY AND DATE(NOW() + INTERVAL 1 DAY)
AND e.profile_binary IS NULL
AND e.source = 'cron'
AND e.status = 'finished'
AND info.vtgate_planner_version = ?
Expand Down Expand Up @@ -262,7 +264,8 @@ func getSummaryLast30Days(workload string, planner PlannerVersion, client storag
JOIN
macrobenchmark_results AS results ON info.macrobenchmark_id = results.macrobenchmark_id
WHERE
e.finished_at BETWEEN DATE(NOW()) - INTERVAL 30 DAY AND DATE(NOW() + INTERVAL 1 DAY)
e.finished_at BETWEEN DATE(NOW()) - INTERVAL 30 DAY AND DATE(NOW() + INTERVAL 1 DAY)
AND e.profile_binary IS NULL
AND e.status = "finished"
AND e.source = "cron"
AND info.vtgate_planner_version = ?
Expand Down

0 comments on commit 1637c54

Please sign in to comment.