Skip to content

ui : cache prebuilt UI assets to skip provisioning - #28754

Closed
ggerganov wants to merge 1 commit into
masterfrom
gg/build-ui-dist-opt
Closed

ggerganov wants to merge 1 commit into
masterfrom
gg/build-ui-dist-opt

Conversation

@ggerganov

Copy link
Copy Markdown
Member

Overview

Add a fast path to the UI asset provisioning script. When the generated ui.cpp/ui.h, asset tree, gzip tree, and cache stamp are unchanged, skip HF download, gzip compression, and asset embedding entirely. Also fix the cache stamp so the requested version is tracked instead of only the fallback latest version.

Additional information

Follow-up to the incremental build overhead discussion in #28445 (comment).

Warm no-change llama-server builds now take about 1s instead of about 5s, with the UI provisioning script itself reduced to about 0.01s.

Cache invalidation is intentional and simple: delete build/tools/ui/.ui-stamp to force regeneration, or bump UI_CACHE_VERSION when cache logic changes.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES. pi:llama.cpp/DeepSeek-V4-Flash-Vision-Exp

Add a fast path to scripts/ui-assets.cmake that skips HF download, gzip and embed work when the generated ui.cpp/ui.h, asset tree, gzip tree and cache stamp are unchanged.

Assisted-by: pi:llama.cpp/DeepSeek-V4-Flash-Vision-Exp
@ggerganov
ggerganov marked this pull request as ready for review September 11, 2026 11:41
@ggerganov
ggerganov requested review from aldehir and angt September 11, 2026 11:41
@aldehir

aldehir commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

A scenario that would still trigger the slow path:

  1. Update master to latest and build. A stamp is created for the current build number.
  2. Create a new branch and commit.
  3. Cache miss. The build number is incremented but unlikely to be present in the HF bucket, so it falls back to latest. If the tag does exist, the assets likely won't match your local repo. Harmless unless you're doing UI changes or the HF assets require a change in the C++ source.
  4. The stamp records the requested build number, so every new commit misses again, re-fetches latest, and runs the slow path in emit_files() even when the archive hasn't changed.
AI-Generated Diagram image

A simple fix would be to stamp on the checksum and check it upfront. A release made between your builds will still trigger the slow path, even if the UI didn't change, simply because the UI is not a reproducible build so the checksum will differ.

@ggerganov

Copy link
Copy Markdown
Member Author

The main use case that I am targeting is running chained commands such as make/ninja && llama .... Since I do this many times during development on a given commit, I want it to be fast.

I had generated an earlier version that was timestamping the UI assets (similar to the suggestion) and the UI cache included a timestamp fingerprint, but the logic was too complicated for almost no benefit. So I decided to simplify to the current version.

I feel the UI build/provisioning is quite complicated at this point and probably it needs to be reworked from scratch. This is just a stopgap until this happens.

@angt

angt commented Sep 12, 2026

Copy link
Copy Markdown
Member

I think we can use a content fingerprint without UI_CACHE_VERSION and still eliminate the 5s overhead on unchanged builds, I had a working draft but got distracted by the N1X and forgot about it...

@angt angt mentioned this pull request Sep 12, 2026
@ggerganov

Copy link
Copy Markdown
Member Author

Superseded by #28802

@ggerganov ggerganov closed this Sep 13, 2026
@ggerganov

Copy link
Copy Markdown
Member Author

Superseded by #28802

@ggerganov
ggerganov deleted the gg/build-ui-dist-opt branch September 13, 2026 17:08
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.

3 participants