Skip to content

Snappier search: facets only for a new query, prefetched pages, a progress bar - #5

Merged
transfix merged 1 commit into
mainfrom
snappy
Oct 30, 2026
Merged

transfix merged 1 commit into
mainfrom
snappy

Conversation

@transfix

Copy link
Copy Markdown
Contributor

Next felt slow. The cause was the server, not the UI: every page asked cvcpkg.org for facets=true, which makes it count every match. Measured on cvcpkg.org (time to first byte):

Request facets=true facets=false
all builds, page 2 1.23 s 0.20 s
"zlib", page 2 2.36 s 0.37 s

Changes

  • Facets only for a new query or filter. That's the only way to get an honest package count; without facets the server counts per page. Paging reuses the first page's count.
  • Prefetch. After showing a page, the search module fetches the next one in the background and keeps the text of the page it left. Next and Prev parse a page already held, with no request.
  • Progress bar. Requests use http-get-async and (await f 0.05) in a loop. Between slices the module draws an indeterminate bar at the bottom of its view; the package module does the same when opening a package. The tick is parked, not blocked, so frames keep drawing.
  • lib.ari gains search-key, body-text and progress-bar (three slices of a constant, cheap enough to redraw 20 times a second). search-query takes facets.

Tests

  • Fixture: logs its requests at /_requests, and answers a slow: name after a second.
  • New module tests:
    • a new query asks for facets and paging doesn't;
    • Next is answered from the prefetched page with no request, and Prev from the page left;
    • the bar draws during a slow request and clears after.
  • Mutation check: with prefetch disabled the search tests fail, and they pass with it.
  • Locally: tests/run.sh passes every layer, including 3d (the integration tests against a real cvcpkg-server). The browser test passes too.

In the browser

In the single-threaded wasm page, network calls still block until the reply arrives, so the bar can't animate there. The prefetch also holds the first frame for one more request: first results took 5.2 s locally, against 3.7 s. The libcvc session working on async fetch in single-threaded wasm (L4) removes that, with no change needed here.

…gress bar

Next was slow because every page asked cvcpkg.org for facets, which
makes it count every match: 1.2 s for page 2 of everything and 2.4 s
for page 2 of zlib, against 0.2 s and 0.4 s without. Now only a new
query or filter asks for facets (the honest package count); paging
reuses that count. After showing a page the search module prefetches
the next one in the background and keeps the page it left, so Next and
Prev are answered with no request.

Requests wait in 50 ms slices (http-get-async and await with a
timeout), and between slices the module draws an indeterminate progress
bar at the bottom of its view; the package module does too. lib.ari
gains search-key, body-text and progress-bar, and search-query takes
facets.

The fixture logs its requests (/_requests) and answers a slow: name
after a second. Module tests show a new query asks for facets and
paging doesn't, Next and Prev make no request, and the bar draws during
a slow request and clears after; with prefetch disabled they fail.
@transfix
transfix merged commit dcc24cf into main Oct 30, 2026
6 checks passed
@transfix
transfix deleted the snappy branch October 30, 2026 22:13
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