Load the metrics of the ML run page page by page
What does this MR do and why?
The Performance tab of an ML run shows every metric of the run, 50 metrics per page with the 100 newest values of each, when the ml_candidate_metrics_pagination feature flag is enabled. Today the page embeds only the 1,000 newest metric rows of a run, so on large runs the metrics logged earlier are missing. The table keeps today's layout, one row per metric and one column per logged step, for the loaded page.
Design notes
- Stacked on !272105 (merged), which adds
Query.mlCandidate,MlCandidate.latestMetricsandMlCandidateLatestMetric.history, and theml_candidate_metrics_paginationflag (gitlab_com_derisk, rollout issue https://gitlab.com/gitlab-org/gitlab/-/work_items/640966). This MR reuses that flag. It targets the backend branch, so merge it after !272105 (merged). app/assets/javascripts/ml/experiment_tracking/routes/candidates/show/candidate_detail.vue: with the flag enabled, the tab runsget_candidate_latest_metrics.query.graphql(latestMetrics(first: 50)withhistory(first: 100)) and pages withGlKeysetPagination. The API pages forward only, so the component keeps a stack ofaftercursors for Previous. The rows go through the same table code as the embedded list, so the table looks the same. The query carries@gl_introduced(version: "19.7.0")onmlCandidate.app/controllers/projects/ml/candidates_controller.rbpushes the flag to the page with the project as the actor.Ml::CandidateDetailsPresenterskips the embeddedmetricsandmetricsTruncatedwhile the flag is enabled, so the page no longer reads the 1,000 newest rows. The truncation alert shows only with the flag disabled.- With the flag disabled, the page keeps today's embedded view and alert.
MAX_EMBEDDED_METRICS, the embedded list and the alert go in the flag removal MR. - Not in this MR: a "load more" control for one metric's older values through
metrics(name:, after:).historyis a list without a cursor, so the first request of such a control would repeat the 100 values already shown. It needs its own design and would push this MR over the size budget.
References
- Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/640899
- Backend MR: !272105 (merged)
- Index the queries need before the flag is enabled: !272094 (merged)
- Rollout issue: https://gitlab.com/gitlab-org/gitlab/-/work_items/640966
Screenshots or screen recordings
A run with 55 metrics and 4 steps each:
| Flag disabled (today) | Flag enabled, page 1 | Flag enabled, page 2 |
|---|---|---|
![]() |
![]() |
![]() |
How to set up and validate locally
-
Check out this branch and log 55 metrics to a run in the Rails console:
c = Ml::Candidate.last 55.times { |i| 4.times { |s| Ml::CandidateMetric.create!(candidate: c, name: format('metric_%02d', i + 1), step: s, value: s) } } Feature.enable(:ml_candidate_metrics_pagination, c.project) Gitlab::Routing.url_helpers.project_ml_candidate_path(c.project, c.iid) -
Open the path from step 1 on
http://gdk.test:3000and select the Performance tab.Expect:
metric_01tometric_50, columns Step 0 to Step 3, and the Next button. -
Select Next.
Expect:
metric_51tometric_55. Previous returns to the first page. -
Run
Feature.disable(:ml_candidate_metrics_pagination, c.project)and reload the page.Expect: all 55 metrics in one table, as on
master.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.


