Skip to content

Speed up server ranking and search on the Your servers dashboard - #1203

Merged
jatmn merged 2 commits into
mainfrom
perf/managed-server-ranking
Dec 6, 2026
Merged

jatmn merged 2 commits into
mainfrom
perf/managed-server-ranking

Conversation

@jatmn

@jatmn jatmn commented Dec 6, 2026 •

Copy link
Copy Markdown
Owner

Performance

The Your servers page previously configured locale-aware collation for every name comparison and reranked server cards on each search edit. This change ranks once per profile, sort mode, error state and locale. Searching filters the ranked entries and retains unchanged cards.

A production-build benchmark in headless Firefox measured 117 ms before and 87 ms after (1.34×) for typing and erasing “study” over a shuffled 200-server profile. Each of the ten input events verifies the exact visible order. Timings cover input dispatch through committed DOM layout. The five paired trial totals were 114/87, 118/87, 117/89, 111/82 and 126/94 ms. Trials alternated revision order after a warm-up pair. The API was local and simulated.

Additional local workload Base PR Speedup
Initial alphabetical ranking in Node 3.579 ms 0.097 ms 37.0×
Default actionable ranking 3.035 ms 0.089 ms 34.3×
Status ranking 2.958 ms 0.101 ms 29.4×
Member-count ranking 1.952 ms 0.067 ms 29.0×
Ten search edits, list preparation in jsdom 13.716 ms 0.331 ms 41.4×
Same jsdom edits, complete input dispatch 218.946 ms 117.531 ms 1.86×

The 100× full-workload target remains open. Production JavaScript shrank by 47 lines. Baseline 87e1dfed74a0.

Correctness

The page properties exercise four sort modes with filtered Unicode names and tied ranks, plus ten combinations of grants and reservation states from the historical sort-eligibility fix in #1182. The filter-only sort-count regression fails on the base and passes here. An SMT model checks that stable filtering preserves the order of every retained pair in a fixed ranking, and that missing member counts follow every known count.

All 643 frontend state tests, 60 supporting frontend tests, the production build, formatting and the WebUI ESLint self-test passed. The eight page-specific tests passed again with the final test assertions.

Summary by Sourcery

Speed up Your servers ranking and search while preserving the selected sort order and existing enrollment behavior.

Enhancements:

  • Rank Your servers entries once per profile, sort mode, error state, and locale, then filter the fixed order as users search.
  • Retain unchanged server cards during filtering to reduce dashboard rendering work.

Tests:

  • Add coverage for search-order stability and sort behavior across locale ties, grants, and reservation states.
Reproduce the two ranking proofs with Z3

Save the following as ranking.smt2 and run z3 ranking.smt2. The expected output is two unsat results. Both were verified after the CI review. The fixed profile and locale assumptions are explicit in the model.

; For any two retained rows in a fixed profile and locale, k is the rank of
; their (primary key, collated name, ID) tuple in the comparator's total preorder.
; The original position breaks complete ties in JavaScript's stable sort.
(set-logic QF_LIRA)
(define-fun before ((ka Int) (ia Int) (kb Int) (ib Int)) Bool
  (or (< ka kb) (and (= ka kb) (< ia ib))))
(declare-const ka Int)
(declare-const kb Int)
(declare-const ia Int)
(declare-const ib Int)
(declare-const fa Int)
(declare-const fb Int)
; Filtering can renumber the two positions, but preserves their relative order.
(push)
(assert (distinct ia ib))
(assert (distinct fa fb))
(assert (= (< ia ib) (< fa fb)))
(assert (distinct (before ka ia kb ib) (before ka fa kb fb)))
(check-sat) ; unsat: sorting then filtering preserves every retained pair.
(pop)

; Member counts are null or finite and nonnegative. Known counts sort largest
; first. Using -1 for a missing count places it after every known count.
(declare-const knownA Bool)
(declare-const knownB Bool)
(declare-const a Real)
(declare-const b Real)
(assert (and (>= a 0) (>= b 0)))
(define-fun countKey ((known Bool) (n Real)) Real (ite known (- n) 1))
(assert (distinct (< (countKey knownA a) (countKey knownB b))
                  (and knownA (or (not knownB) (> a b)))))
(check-sat) ; unsat

pullfrog[bot]
pullfrog Bot previously approved these changes Dec 6, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No blocking issues. One CI finding below.

Approach
Ranking once per profile and sort is a good fit because filtering preserves the relative order of matching servers.

Reviewed changes

  • Ranking and search. Reuse one collator per ranking, filter the ranked rows on each search edit, and preserve name and ID tie-breaks and the missing-member-count fallback.
  • Server cards and actions. Memoize cards across search edits and preserve enrollment eligibility for current and older API responses.
  • Validation. Review the standalone ordering model and rerun all eight dashboard state tests in jsdom. The search-order test also passed with Swedish default collation.

Non-blocking

  • The standalone SMT model triggers the full CI matrix. Running the check planner with the PR paths selects every group because the model path is unclassified. The full matrix has no step that runs a solver. Drop the standalone file and keep the state test as the regression check for the JavaScript implementation. Model · CI planner

Pullfrog  | Fix it ➔ | View workflow run | Using gpt-6.2-sol | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Removed the standalone ranking model. The PR description preserves the same proof. I verified that the remaining paths select six affected CI groups, including the frontend checks, and that the dashboard regression tests are unchanged in 8fd55d2.

Pullfrog  | View workflow run | Using gpt-6.2-sol | 𝕏

@jatmn
jatmn marked this pull request as ready for review December 6, 2026 21:35
@jatmn jatmn self-assigned this Dec 6, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@jatmn
jatmn merged commit fd2c813 into main Dec 6, 2026
18 checks passed
@jatmn
jatmn deleted the perf/managed-server-ranking branch December 6, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant